New "Contributed" Tags and Filters for a the Browser and Dojo
To Use
These tag/filter sets can be included with either dojo.require, or the {% load %}
tag.
Attribute Tags
Before we get to the list, it's important to note that HtmlTemplate considers attributes to be a full-fledged part of the template system. What this means is that there are new tags that have been introduced that use named attributes in order perform new actions. For the curious tag author, this is accomplished by registering a named tag with "attr:" in front of it
dojox.dtl.contrib.dijit
These tags are only applicable to the HTML version of the template system. If you want the same behavior in a text-based environment, you have to use the dojox.dtl._Templated mixin on a widget. These tags will work even if they are used outside of dojox.dtl._HtmlTemplated.
- Node Attribute: dojoType: If widgetsInTemplate is set on a widget, or if the global dojox.dtl.contrib.dijit.widgetsInTemplate is set, the node will be instantiated as a widget of that type.
- Node Attribute: dojoAttachPoint: Works exactly the same as the Dijit templated equivalent
- Node Attribute: attach/dojoAttachPoint: Works exactly the same as the Dijit templated equivalent
- Node Attribute: dojoAttachEvent: Works exactly the same as the Dijit templated equivalent
- Note Attribute: onclick/onmouseover/etc: The string you have in its value is the name of the function to call when that action is performed. eg onclick="goHome"
dojox.dtl.contrib.html
These are also only applicable to the HTML version. The html tag is especially important because, without it, the variable contents are always rendered as text.
- html: If you want to render a variable as HTML, you have to use {% html varName %}
- Node Attribute: tstyle: Use if you want to change style attributes during rendering. eg tstyle="top: {{ y }}px;"
dojox.dtl.contrib.data
This allows you to take a given data store, a given list of items, and assign them to a single variable that can be used as if each item was a normal variable.
In the example below, {{ item.title }}
will be the equivalent of calling: store.getValue(item, "title"};
{% for item in flickrItems %}{{ item.title }}: {{ item.description }}{% endfor %}
You can also use: {{ item.getLabel }}, {{ item.getAttributes }}, and {{ item.getIdentity }}
Note that there's a little weirdness with getValue and getValues. If you want to be sure that getValues is called, just add an extra "s" to the end of your variable name.
- Printer-friendly version
- Login or register to post comments
- Subscribe post