Welcome to jaiml’s documentation!¶
jaiml is a module for writing aiml with the help of Jinja2 which is a python template engine.
Quick start¶
In this module all the features of Jinja2 templates are available, but mostly you will use the for block which is exactly as a regular python for as you can see bellow.
- Example 1 - jinja for block:
{% for i in foo_list %} <category> <pattern>{{ i }}</pattern> <template><srai>FOO</srai></template> </category> {% endfor %}On this example a category will be created for every element i in foo_list and they will be the same except for the i value.
The next example shows how to use this module.
- Example 2 - how to use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from jaiml import JaimlManager manager = JaimlManager(__name__, brain_file=False) @manager.marker def foo(): buffer = """ {% for i in greetings %} <category> <pattern>{{ i }}</pattern> <template><srai>HELLO</srai></template> </category> {% endfor %} """ grts = ['HELLO _', 'HI', 'HI _', 'HEY', 'HEY _'] vars = {'greetings': grts} return buffer, vars print(manager.get_output())This is the basic structure needed to use jaiml. At line 3 __name__ will be treated later but if brain_file was set to True JaimlManager would create an aiml output file called by default brain.aiml.
The decorator
jaiml.JaimlManager.marker()
at line 5 marks the function as an jaiml provider then the manager can handle it.In the 15 line we have the list of patterns to be replaced on i at line 8 and this list is added to a dictionary. This is an importat step because this dictionary is for passing any variable that you have used on your template, in this case greetings. Also the key containing the variable must have the same name as the used on template.
An other way(the recomended one) to define the Example 2 foo function is:
@manager.marker def foo(): grts = ['HELLO _', 'HI', 'HI _', 'HEY', 'HEY _'] vars = {'greetings': grts} return 'foo_example_file.xml', varsfoo_example_file.xml is a file containing the what was in buffer. The template files directorie by default is called jinja-templates and must be placed at the same directorie as __name__. The extension .xml should be used because in this way IDEs can do syntax highlight but also are supported extensions .jinja, .j2, and .aiml.


--- layout: post title: First steps with Jasmine tags: - bdd - jasmine - JavaScript - node.js - tdd status: publish type: post published: true comments: true meta: aktt_notify_twitter: 'no' _edit_last: '2' _social_aggregation_log: a:10:{i:1365163591;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365165882;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365168606;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365172212;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365179497;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365194672;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365223600;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365267553;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365354029;O:8:"stdClass":1:{s:6:"manual";b:0;}i:1365526854;O:8:"stdClass":1:{s:6:"manual";b:0;}} _social_notify: '1' _social_aggregated_ids: a:2:{s:7:"twitter";a:0:{}s:8:"facebook";a:0:{}} ---
New job and opportunities. One of the core approaches to developing here, is the use TDD. Now in a JS/UI kind of role this is really novel approach (well at least for me). I don't know how many times in the past I have lamented the fact that I needed to click through way too many steps to get to the issue at hand and then rinse and repeat to debug/fix. Even once I had wrapped my head round Chrome's debugger this approach still took way too long. I had dabbled a little in TDD and BDD on personal ruby projects, but never from a UI perspective and when faced with a monumental UI code base I just didn't have the stomach to tackle the problem retro fit tests. Also to be honest the JavaScript testing frameworks just didn't click with me, until Node.js and Jasmine that is. With Node.js installed grab the following modules using npm
Easiest way to get tests running type 'node ./spec.js ' at the command line, which is pointing to ./spec/ folder. In my BlogSpec.js file let's start with some basic tests
describe('blog creation', function() {
it('should have a title attribute', function(){
expect(testBlog.title).toBeDefined();
});
it('should have a title', function() {
expect(testBlog.title).not.toBeNull();
});
});
When you run the spec with : 'node-blog git:(master) ✗ node spec.js' the test should fail
Started FF Spec blog creation it should have a title attribute Error: ReferenceError: testBlog is not defined at new <anonymous>
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:94:50) at [object Object].fail
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:1963:27) at [object Object].execute
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:970:15) at [object Object].next\_
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:1739:31) at [object Object].start
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:1692:8) at [object Object].execute
(/Users/gregstewart/Projects/node-blog/node\_modules/jasmine-node/lib/jasmine-node/jasmine-1.0.1.js:2018:14) at [object Object].next\_
(/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmin%
So everything is as expected at this stage, let's start work on getting the basic tests to pass. First off let's create out Blog object
Blog = function(title) {
this.title = title;
}
Blog.prototype.getTitle = function() {
return this.title;
};
exports.Blog = Blog;
And not let's bring the Blog object into our test and initialise it:
var Blog = require('../Blog').Blog;
describe('blog creation', function() {
var testBlog; beforeEach(function() {
testBlog = new Blog();
});
it('should have a title attribute', function(){
expect(testBlog.title).toBeDefined();
});
it('should have a title', function() {
expect(testBlog.title).not.toBeNull();
});
});
Now let's get the first test to pass, by editing our Blog.js file
Blog = function(title) {
this.title = typeof title !== 'undefined' ? title : null;
}
Blog.prototype.getTitle = function() {
return this.title;
};
exports.Blog = Blog;
Nearly there, only problem is that our second test is failing because we require a title to not be null.
var Blog = require('../Blog').Blog;
describe('blog creation', function() {
var testBlog;
beforeEach(function() {
testBlog = new Blog('test');
});
it('should have a title attribute', function(){
expect(testBlog.title).toBeDefined();
});
it('should have a title value', function() {
expect(testBlog.title).not.toBeNull();
});
});
Let's see what the output looks like:
➜ node-blog git:(master) ✗ node spec.js Started .. Spec blog creation Finished in 0.001 seconds 1 test, 2 assertions, 0 failures
And just because I can, let's rewrite the Blog.js in Coffee Script:
class Blog
constructor:(@title) ->
getTitle: -> @title
exports.Blog = Blog;
How much terser is that?


_Confirm access for clientID_
_You are logged in as userName._
_The client clientId is requesting access to your data on this IRIDA site. Approving this request will allow clientId allowedScopes access to the following resources on this site:_
- Projects
- Samples
- Sequence files
_Note: clientId has been authorized as part of the IRIDA network by the site's administrators._


Please enter first name
Please enter last name
Please enter mobile number
Please select a pin
Please enter same pin
Please accept terms & conditions


{% block head %} {% endblock %}
Campus Resources
Academics
Health
Organizations
About Us
{% block content %} {% endblock %}


Test quality information John's Garage
{{releaseVersion | log }}This information will help you manage the quality of testing at your site. How you use it will depend on how you manage the site, its size and number of staff.
Tests done in April 2017
Group A
| Tester | Tests done | Average vehicle age | Average test time | Tests failed | Failures by category |
|---|---|---|---|---|---|
| Bob Thomas Arctor | 0 | - | - | 0% | View |
| National average | 9 | 14y | 37m | 42% |
Download group A data
Download the group A report as a CSV (spreadsheet) file (198kb)
What's in this file?
This file contains:
- test quality information for all group A testers associated to the site over the date range selected
- all group A testers' failures by category over the date range selected
Group B
| Tester | Tests done | Average vehicle age | Average test time | Tests failed | Failures by category |
|---|---|---|---|---|---|
| Bob Thomas Arctor | 102 | 12y | 35m | 24% | View |
| Pam Poovey | 48 | 11y | 38m | 67% | View |
| Lana Kane | 0 | - | - | 0% | View |
| National average | 9 | 14y | 37m | 42% |
Download group B data
Download the group B report as a CSV (spreadsheet) file (198kb)
What's in this file?
This file contains:
- test quality information for all group B testers associated to the site over the date range selected
- all group B testers' failures by category over the date range selected


Greatness through Guidance is a non-profit organization that provides curriculums and counseling in financial literacy, digital literacy, and career advice to American students who are not educated in these subjects. We plan to do so by conducting educational classes in Philadelphia, PA. As we grow, our movement will reach from sea to shining sea.
At Greatness through Guidance, we envision a world where everyone is empowered and equipped to succeed in life.


{% extends "auth/base_auth.html" %} {% import "_macros.html" as macros %} {% block title %}Conferency | Login{% endblock %} {% block head %} {{ super() }} {% endblock %} {% block main_form %}
Welcome. You are invited to join {{ conference.name }} as {{ role }}{% if not track.default %} of {{ track.name }}{% endif %}, please login to accept.
{% else %}


COST CALCULATOR
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
- Area to be Renovated in Square Feet:
- Walls & Ceilings:
- Floors:
- Interior Doors to Replace:
- Windows to Replace:
Project Cost:
$2,300.00
- Length of your Fence in feet:
- Height of Your Fence in Feet:
- Choose Panel Style:
- Choose Gate Type:
- Additional Extras:
Project Cost:
$2,300.00
- Approximate Area Width in Meters:
- Approximate Area Length in Meters:
- Choose Block Paving:
- Stone Walling in Meters:
- Surface Preparation
Project Cost:
$2,300.00
consectetur adipisicing elit sed do eiusmod tempor incididunt.
Sign Up


--- layout: post title: '#DBHangOps Madness! 3/13/13' categories: - computing - database - mysql tags: - '#DBHangOps' - database - HangOps - mysql - mysql_planet status: publish type: post published: true meta: _edit_last: '1' _aioseop_title: '#DBHangOps Madness! 3/13/13' _aioseop_description: "Pop into the google hangout on March 13th at 12:00pm PST for #DBHangops!\r\nThis week's topics include: monitoring, tech demos, and bug talk!" _aioseop_keywords: '#DBHangOps, linux, database, mysql, dba, hangout' _wpas_done_all: '1' _wpas_skip_3039720: '1' _wpas_skip_3039727: '1' _wpas_skip_3039731: '1' _wpas_skip_3039741: '1' --- Here's the recording! Heyo! March 13th at 12:00pm PDT (19:00 GMT) is the time to check in and hop online for #DBHangOps this week. Keep an ever watchful eye on the twitter search and hop on the google hangout to contribute some discussion! This week's topics are:


Complete Your Service Booking
Lawn mowing
Date: 20 MAR 2018
Time: 10:00 a.m to 01:00 p.m
Lawn Size: 1.50 - 2.00 acres
Service Address
Tom Wilson
29 Sleepy Hollow Drive, Hamilton Parish, BermudaM
Phone: (123) 123-456
E-Mail<EMAIL_ADDRESS>Price Details
Single $ 120.00
Tax Rate0.00 %
Grand Total$ 120.00


{% extends "common/base.html" %} {% block content %}
Press the below button to wipe your personal DB on this site, note this can not be undone.


Exercise 1: Driving behavior through properties (XAM320)
In this exercise, you'll add in selection support, and use data triggers to change the UI based on property values exposed in view models.
To complete the exercise, you will need Visual Studio for Windows or macOS with the Xamarin development tools installed. You will also need either an emulator/simulator or a device to run the exercise on. Please see the setup page if you need help installing the Xamarin development environment.
Open the starter solution
Open the starter solution from the Exercise 1 > Start folder in your copy of the cloned or downloaded course materials in either Visual Studio on Windows or Visual Studio for Mac.
Build and run the application to make sure it is working before making changes. It displays quotes using an XML data file as the backing storage. There are two projects that implement the data infrastructure:
-
GreatQuotes
This is the shared PCL which contains the XAML pages, converters and common data structures used in the application. The common data used is in the Data folder and consists of three files:
- GreatQuote.cs is a model class for a single quote.
- IQuoteLoader.cs is an interface which is implemented by the QuoteLoader class in the shared project which is used to load and save the quotes to an XML file.
- QuoteManager.cs is a static class with two static methods to load and save the quotes. It resolves IQuoteLoader from the Xamarin.Forms Dependency Service.
-
GreatQuotes.Data
This is a Shared Project which contains a single source file to load the quotes from an XML file.
-
QuoteLoader.cs is a static class which implements the
IQuoteLoader
interface. It uses compiler directives to split up the platform specific code. This class is loaded into the Xamarin.Forms Dependency Service.
-
QuoteLoader.cs is a static class which implements the
Add selection support
Your first step is to add some property support for selection.
- Open the
MainViewModel
and add a new public property of typeQuoteViewModel
named SelectedQuote. Use a public getter and setter, and use a backing field. -
Make sure to implement property change notification when setting the new property - as a quick shortcut, you can use the
SetPropertyValue
method from the base view model - this will set the underlying field and raise a property change notification for you. It has the form:SetPropertyValue<T>(ref T field, T newValue);
QuoteViewModel selectedQuote; public QuoteViewModel SelectedQuote { get { return selectedQuote; } set { SetPropertyValue(ref selectedQuote, value); } }
-
Next, let's use the property. Open the QuoteListPage.xaml file and locate the
ListView
. Add a new property binding for theSelectedItem
property to the view model property. Use a two-way binding (Mode
property). Leave theItemTapped
event handler in place, you still need that for the moment to handle navigation.<ListView ItemsSource="{Binding Quotes}" SelectedItem="{Binding SelectedQuote, Mode=TwoWay}" ItemTapped="OnQuoteSelected">
-
Next, open the code behind file (QuoteListPage.xaml.cs) and locate the
OnQuoteSelected
method. It's currently passing the tapped item to theQuoteDetailPage
as part of the constructor. Remove the parameter, you don't need it anymore as long as the second page has access to the view model! - Finally, open the QuoteDetailPage.xaml.cs file and fix the constructor to not take the parameter. Instead, change the
BindingContext
to be theSelectedQuote
property of theMainViewModel
. Remember the view model is a singleton exposed by theApp
class. - Run the application and make sure it still works properly - it should correctly navigate and still display the quote details when it's on the second screen. However, there is a minor, but annoying bug on some platforms. When you return to the original screen, the
ListView
still shows selection and the cell you tapped on is highlighted. Let's fix that. - In the
QuoteDetailPage
constructor, clear theSelectedQuote
property (set it tonull
) after you set theBindingContext
. This will clear theListView
selection. - Run the app again to verify the change.
Use DataTriggers
If you examine the QuoteListPage
or QuoteDetailPage
XAML, you will find it uses a value converter named GenderToColorConverter
which is located in the Converters folder. This is located in the application resources and reused on both pages. You're going to remove it from the second page.
- Open the
QuoteDetailPage
XAML file and locate theLabel
which displays the author name. - Change the
TextColor
property to just be "Blue" and remove the binding. Now all quote authors will be in blue. - Add a
DataTrigger
to theLabel
which changes theTextColor
property when theGender
isGender.Female
. Refer to the slides if you need some guidance, or check the code hint below. - Run the application and navigate to the Eleanor Roosevelt quote. The quote author at the bottom of the page should be in pink.
- You might want to use the same technique on the
QuoteListPage
as well - however it won't work there. That's using aTextCell
to display the quote - and unfortunately,TextCell
does not derive fromVisualElement
where the trigger support lives. So, it will either need to be changed to aViewCell
with a fullLabel
(which is less efficient thanTextCell
), or continue using a converter. Here, you've chosen the latter as it doesn't hurt anything, however you could try the former if you have some extra time.
<Label Grid.Row="1" Text="{Binding Author}"
TextColor="Blue"
HorizontalOptions="End" HorizontalTextAlignment="End">
<Label.Triggers>
<DataTrigger TargetType="Label"
Binding="{Binding Gender}"
Value="Female">
<Setter Property="TextColor" Value="Pink" />
</DataTrigger>
</Label.Triggers>
</Label>
Exercise summary
In this exercise, you've pushed the selection management into the view model and started removing value converters, instead relying on properties with triggers to control the visual properties.
You can view the completed solution in the Exercise 1 > Completed folder of your copy of the cloned or downloaded course materials.