source: Dev/branches/rest-dojo-ui/client/dojox/dtl/README @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 10.7 KB
Line 
1-------------------------------------------------------------------------------
2DojoX Django Template Language
3-------------------------------------------------------------------------------
4Version 0.0
5Release date: 09/20/2007
6-------------------------------------------------------------------------------
7Project state: experimental/feature incomplete
8-------------------------------------------------------------------------------
9Project authors
10        Neil Roberts (pottedmeat@dojotoolkit.org)
11-------------------------------------------------------------------------------
12Project description
13
14The Django Template language uses a system of templates that can be compiled
15once and rendered indefinitely afterwards. It uses a simple system of tags
16and filters.
17
18This is a 1:1 match with the Django Template Language as outlined in
19http://www.djangoproject.com/documentation/templates/. All applicable tags and
20filters have been implemented (see below), along with new filters and tags as
21necessary (see below).
22
23The Django Template Language is intended within Django to only handle text.
24Our implementation is able to handle HTML in addition to text. Actually, the
25text and HTML portions of dojox.dtl are two separate layers, the HTML layer
26sits on top of the text layer (base). It's also been implemented in such a way
27that you have little to fear when moving your code from Django to dojox.dtl.
28Your existing templates should work, and will benefit from the massive
29performance gain of being able to manipulate nodes, rather than having to do
30clunky innerHTML swaps you would have to do with a text-only system. It also
31allows for new HTML-centric abilities, outlined below.
32
33Despite having two levels of complexity, if you write your tags correctly, they
34will work in both environments.
35-------------------------------------------------------------------------------
36Dependencies
37
38Base:
39dojox.string.Builder
40
41Date filters and tags:
42dojox.date.php
43
44Widget:
45dijit._Widget
46dijit._Container
47-------------------------------------------------------------------------------
48Installation instructions
49
50Grab the following from the Dojo SVN Repository:
51http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl.js
52http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl/*
53
54Install into the following directory structure:
55/dojox/dtl/
56
57...which should be at the same level as your Dojo checkout.
58-------------------------------------------------------------------------------
59What's Been Done
60
61Note: HTML Unit Tests should only be around for the oddities of HTML, tag/filter
62code is the same for each environment with minor exceptions. Cloning of all tags
63should be tested inside a for loop.
64
65| Implemented |     Tag     | Text Unit Test | HTML Unit Test |
66|      X      | block       |       X        |                |
67|      X      | comment     |       X        |                |
68|      X      | cycle       |       X        |                |
69|      X      | debug       |       X        |                |
70|      X      | extends     |       X        |                |
71|      X      | filter      |       X        |                |
72|      X      | firstof     |       X        |                |
73|      X      | for         |       X        |                |
74|      X      | if          |       X        |                |
75|      X      | ifchanged   |       X        |       X        |
76|      X      | ifequal     |       X        |                |
77|      X      | ifnotequal  |       X        |                |
78|      X      | include     |       X        |       X        |
79|      X      | load        |       X        |                |
80|      X      | now         |       X        |                |
81|      X      | regroup     |       X        |                |
82|      X      | spaceless   |       X        |       X        |
83|      X      | ssi         |       X        |       X        |
84|      X      | templatetag |       X        |                |
85|     N/A     | url         |                |                |
86|      X      | widthratio  |       X        |                |
87|      X      | with        |       X        |                |
88
89| Implemented | Filter             | Text Unit Test | HTML Unit Test |
90|      X      | add                |       X        |                |
91|      X      | addslashes         |       X        |                |
92|      X      | capfirst           |       X        |                |
93|      X      | center             |       X        |                |
94|      X      | cut                |       X        |                |
95|      X      | date               |       X        |                |
96|      X      | default            |       X        |                |
97|      X      | default_if_none    |       X        |                |
98|      X      | dictsort           |       X        |                |
99|      X      | dictsort_reversed  |       X        |                |
100|      X      | divisibleby        |       X        |                |
101|      X      | escape             |       X        |                |
102|      X      | filesizeformat     |       X        |                |
103|      X      | first              |       X        |                |
104|      X      | fix_ampersands     |       X        |                |
105|      X      | floatformat        |       X        |                |
106|      X      | get_digit          |       X        |                |
107|      X      | iriencode          |       X        |                |
108|      X      | join               |       X        |                |
109|      X      | length             |       X        |                |
110|      X      | length_is          |       X        |                |
111|      X      | linebreaks         |       X        |                |
112|      X      | linebreaksbr       |       X        |                |
113|      X      | linenumbers        |       X        |                |
114|      X      | ljust              |       X        |                |
115|      X      | lower              |       X        |                |
116|      X      | make_list          |       X        |                |
117|      X      | phone2numeric      |       X        |                |
118|      X      | pluralize          |       X        |                |
119|      X      | pprint             |       X        |                |
120|      X      | random             |       X        |                |
121|      X      | removetags         |       X        |                |
122|      X      | rjust              |       X        |                |
123|      X      | slice              |       X        |                |
124|      X      | slugify            |       X        |                |
125|      X      | stringformat       |       X        |                |
126|      X      | striptags          |       X        |                |
127|      X      | time               |       X        |                |
128|      X      | timesince          |       X        |                |
129|      X      | timeuntil          |       X        |                |
130|      X      | title              |       X        |                |
131|      X      | truncatewords      |       X        |                |
132|      X      | truncatewords_html |       X        |                |
133|      X      | unordered_list     |       X        |                |
134|      X      | upper              |       X        |                |
135|      X      | urlencode          |       X        |                |
136|      X      | urlize             |       X        |                |
137|      X      | urlizetrunc        |       X        |                |
138|      X      | wordcount          |       X        |                |
139|      X      | wordwrap           |       X        |                |
140|      X      | yesno              |       X        |                |
141-------------------------------------------------------------------------------
142HTML-Specific Additions
143-------------------------------------------------------------------------------
144{%extends "shared:templates/template.html" %}
145
146When using the {% extends %} tag, we don't always want to replace the parent
147node in DOM. For example, if we have a list view and a detail view, but both
148share the same base template, we want it to share the parent template. This
149basically means that the same nodes will be used in the parent for both views.
150
151To use this, simply add "shared:" to the beginning of the specified template.
152-------------------------------------------------------------------------------
153<!--{% commented markup %}-->
154
155Some browsers treat comment nodes as full fledged nodes. If performance is
156important to you, you can wrap your markup in comments. The comments will be
157automatically stripped for browsers that cannot support this.
158-------------------------------------------------------------------------------
159Attribute Tags
160
161If a tag name begins with "attr:" then it will be able to inject an object
162into the parsed template. (See dojox.dtl.tag.event.EventNode)
163
164onclick/onmouseover/etc attributes work by attaching to the rendering object.
165
166tstyle attribute allows for styles to be changed dynamically. Use them just
167like a "style" attribute.
168
169attach attribute attaches the node to the rendering object.
170-------------------------------------------------------------------------------
171New Context Functions
172
173setThis() and getThis() returns the object "in charge" of the current rendering.
174This is used so that we can attach events.
175
176mixin() and filter() clone the current context, and either add to or reduce
177the keys in the context.
178-------------------------------------------------------------------------------
179Buffers
180
181Both the base and HTML versions of dojox.dtl use buffers. The base version uses
182dojox.string.Builder and the HTML version uses dojox.dtl.DomBuffer.
183
184The HTML buffer has several calls important to rendering:
185
186setParent/getParent/concat/remove:
187
188setParent and concat are used in order to render our HTML. As we move through
189the parsed template, different nodes change the parent or add on to the
190current parent. getParent is useful in things like the attribute tags, since
191they can use getParent to find the node that they're an attribute on. remove is
192used during unrendering.
193
194setAttribute:
195
196Sets an attribute on the current parent
197-------------------------------------------------------------------------------
198Tags Need clone/unrender Functions.
199
200One of the biggest challenges of getting dojox.dtl to work in an HTML
201environment was logic blocks. Nodes and objects inside a for loop need to be
202cloned, they can't simply be re-rendered, especially if they involve a Node.
203Also, in the case of an if/else block, we need to be able to not just render
204one of the blocks, but also unrender the second.
205
206This is really simple code, a good example is the dojox.dtl.DomNode
207object. Each function in this object is only one line long.
Note: See TracBrowser for help on using the repository browser.