username@email.com
2021-09-02 9da546cd8de37882147f19f6f090544476bfe5ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
-----------------------------------
-   jTemplates 0.8.4 by tPython   -
-  http://jtemplates.tpython.com  -
-----------------------------------
 
 
Tags:
{|CODE|} - evaluate COND
{#if |COND|}..{#elseif |COND|}..{#else}..{#/if}
{#foreach |VAR| as |NAME| [begin=|CODE|] [count=|CODE|] [step=|CODE|]}..{#else}..{#/for}
{#foreach |FUNC| as |NAME| [begin=|CODE|] [end=|CODE|] [count=|CODE|] [step=|CODE|]}..{#else}..{#/for}
{#for |VAR| = |CODE| to |CODE| [step=|CODE|]}..{#else}..{#/for}
{#continue}
{#break}
{#include |NAME| [root=|VAR|]}
{#param name=|NAME| value=|CODE|}
{#var |CODE|}
{#cycle values=|ARRAY|}
{#ldelim}
{#rdelim}
{#literal}..{#/literal}
{*..*} - comment
 
where:
|CODE|   - JavaScript code
|COND|   - JavaScript condition
|NAME|   - String
|NUMBER| - Number
|ARRAY|  - Array
|VAR|    - Variable
|FUNC|   - Function
 
--------------------------------------------------------------------------------
 
Templates:
{#template <name> [<param1>=<arg1>] [<paramX>=<argX>]}
..
{#/template <name>}
 
Main template:
{#template MAIN}
..
{#/template MAIN}
 
--------------------------------------------------------------------------------
 
Tag's details:
 
|VAR| and |CODE| and |COND| can use:
 $T - data
 $P - parameters
 $Q - HTML Element
 
|VAR:foreach| & |VAR:for|:
 $index
 $iteration
 $first
 $last
 $total
 $key - key in object
 $typeof - type of element
examples:
 $T.item$index
 $T.item$key
 
Members:
 $T.<name>
examples:
 $T.name
 $T.id
 
Tables:
 $T[<index>]
examples:
 $T[0]
 $T[1]
 
--------------------------------------------------------------------------------
 
Plugin to jQuery:
jQuery jQuery.fn.setTemplate(String template, [Array includes], [Object settings]);
jQuery jQuery.fn.setTemplate(Template template);
jQuery jQuery.fn.setTemplateURL(String url, [Array includes], [Object settings]);
jQuery jQuery.fn.setTemplateElement(String elementName, [Array includes], [Object settings]);
 
Template jQuery.createTemplate(String template, [Array includes], [Object settings]);
Template jQuery.createTemplateURL(String url, [Array includes], [Object settings]);
Template jQuery.getTemplate(Element element);
string jQuery.processTemplateToText(Template template, [Object data], [Object parameter]);
 
Number jQuery.fn.hasTemplate();
 
jQuery jQuery.fn.removeTemplate();
 
jQuery jQuery.fn.setParam(String name, Object value);
 
jQuery jQuery.fn.processTemplate(Object data, [Object parameters]);
jQuery jQuery.fn.processTemplateURL(String url, [Object parameters], [Object options]);
 
Updater jQuery.fn.processTemplateStart(String url, Array param, Integer interval, [Array args], [Object options]);
jQuery jQuery.fn.processTemplateStop();
 
jQuery.jTemplatesDebugMode(Boolean value);
 
--------------------------------------------------------------------------------
 
Template's settings:
disallow_functions - forbid use functions in data $T [default: false, depend on: clone_data, clone_params]
filter_data - replace chars: <, >, &, ' and " in data $T to HTML entities [default: true, depend on: clone_data]
filter_params - replace chars: <, >, &, ' and " in parameters $P to HTML entities [default: false, depend on: clone_params]
runnable_functions - automatically run function (from data) inside {} [default: false]
clone_data - clone input data [default: true]
clone_params - clone input parameters [default: true]
f_cloneData - Function used to data cloning [default: TemplateUtils.cloneData]
f_escapeString - Function used to escape strings [default: TemplateUtils.escapeHTML]
f_parseJSON - Function used to parse JSON [defaults are: jQuery.parseJSON (when disallow_functions) or TemplateUtils.parseJSON (when not disallow_functions)]
 
--------------------------------------------------------------------------------
 
Callbacks and options:
 
* jQuery.fn.processTemplateURL:
type - 'GET' or 'POST', default: 'GET'
data - Data to be sent to the server. Default: undefined
dataFilter - A function to be used to handle the raw response data of XMLHttpRequest. Default: undefined
async - asynchronous AJAX, default: true
cache - use cache, default: false
timeout - Set a local timeout in ms for the request.
on_success [event] - Run after success
on_error [event] - Run on error
on_complete [event] - Run after success and error
 
--------------------------------------------------------------------------------
 
Internal Templates API:
Template::Template(String template, [Array includes], [Array settings]);
void Template::setTemplate(String template, [Array includes]);
String Template::get(Object data, Object parameters, HTMLElement element, Number deep);
void Template::setParam(String name, Object value);
Template.DEBUG_MODE
 
--------------------------------------------------------------------------------
 
XHTML with embedded Templates.
How to embedded the template:
1) Simple:
    <textarea id="name" style="display:none">
        ... templates ...
    </textarea>
 
2) Valid XHTML 1.1:
    <p style="display:none"><textarea id="name" rows="0" cols="0"><![CDATA[
        ... templates ...
    ]]></textarea></p>
 
3) Using comment:
<p style="display:none"><textarea id="name" rows="0" cols="0"><!--
    ... templates ...
--></textarea></p>
 
--------------------------------------------------------------------------------
 
Known bugs:
- comments has higher priority than literals
- literal does not work good when template is embedded with XHTML document
- ajax-based methods does not work in Opera Mini with data compression enabled
 
--------------------------------------------------------------------------------
 
Changelog:
 
0.8.4 (25.01.2013):
- fix bug with multiple {#literal}
- small changes
 
0.8.3 (06.08.2012):
- compability with jQuery up to 1.8/1.9
- fix bug with elseif..else
- small changes
 
0.8.2 (21.05.2012):
- improve recursive template
- processTemplate no longer create a copy of HTML elements
- remove $Q.version, you can use Template.version
- fixed the problem with some android browsers
- fixed the problem with IE7 and some CSS styles
- fixed the problem with subtemplates in some cases
 
0.8.1 (31.01.2012):
- fixed bug with #for and IE 6/7, improve performance
- set default type 'GET' for setTemplateURL() and createTemplateURL()
- change: method processTemplateURL use jQuery.ajaxSettings
 
0.8 (27.11.2011):
- add {#var}
- dedicated environment for eval()
- fix problem with using characters '{' and '}' inside template block {...}
- change default DEBUG_MODE to false
- add loop limit FOREACH_LOOP_LIMIT
- add Template function handler: f_parseJSON with default method TemplateUtils.parseJSON
- some small changes
 
0.7.8 (02.04.2009):
- add {#break} and {#continue}
- new function: jQuery.processTemplateToText
- new function: jQuery.getTemplate
- restore: #foreach will have access to all content (not only loop variable)
- fix compatibility with jQuery.noConflict
- some other small fixes
 
0.7.5 (30.08.2008):
- add options and callbacks for processTemplateURL and processTemplateStart
- allow to use <!-- --> instead <[CDATA[ ]]> as template container (due to issue with cascading textarea)
- allow to define own function for clones data and filters strings
- add debug mode (when off - disable most off errors)
- fix a bug with FOREACH over Object and toString
 
0.7.0 (11.05.2008):
- tag {#for...}
- clone_data & clone_params
- fix a bug with 'runnable functions' and toString in IE
 
0.6.9 (11.05.2008):
- function as loop in foreach (till function return undefined)
- embedded settings in subtemplates
- remove backwards compatibility
 
0.6.8 (10.05.2008):
- fix a bug with filtering data in subtemplates
 
0.6.7 (10.05.2008):
- chainable functions
 
0.6.6 (06.01.2008):
- fixed bug: {#cycle} not work correctly between templates in multitemplate mode
- code cleanup
 
0.6.5 (05.01.2008):
- new: embedded templates
- new function: setTemplateElement(String elementName, Array includes, Object settings)
 
0.6.0 (25.12.2007):
- add #foreach over object
- new |VAR:foreach|:
  $key
    $typeof
- allow function in data by default (disallow_functions = false)
- automatically run function (from data) inside {} ("runnable function")
- add setting: runnable_functions (default: false)
- fix a bug with pseudo-attributes |VAR:foreach| like: $index, $total...
  new syntax for |VAR:foreach|, example:
     $T.item.$index -> $T.item$index
 
0.5.1 (04.12.2007):
- fix bug with #cycle
 
0.5.0 (19.09.2007):
- update documentations
- add removeTemplate()
 
0.4.5 (18.09.2007):
- compatibility with jQuery 1.2.1 (does not work with 1.2)
- block {} return empty string instead of 'undefined', so code in {} does not need to return any value
- disable cache in processTemplateURL
- small fixed
 
0.4.3 (25.08.2007):
- major bugfix with variables scope (thanks to: S. Keshavarzi)
 
0.4.2 (16.08.2007):
- compatibility with $.noConflict() (need more tests)
 
0.4.1 (27.07.2007):
- add jQuery.fn.hasTemplate
 
0.4: (27.07.2007):
- improve security
  Add filters to encode HTML entities and detect function in data.
- add settings: disallow_functions, filter_data, filter_params
- jTemplates use clone of data and parameters, so original data won't be changed after processing.
 
0.3: (17.07.2007):
- LiveRefresh:
  - processTemplateStart()
  - processTemplateStop()
 
0.2.2: (14.07.07)
- add {#elseif}
 
0.2.1: (14.07.07)
- fix issue with include (bug with attribute 'root')
 
0.2.0: (12.07.07)
- MultiTemplates
- fix bug with literal
- memory usage reduce & speed up
- some more...
 
 
 
--------------------------------------------------------------------------------
--
Tomasz Gloc, 2007-2013