Helma Logo
main list history

Version 54 by Lehni on 22. April 2007, 07:23

163 0.24  Added browser support. Tested on Safari and Firefox.
164      Fixed a bug in conditional statements containing '=='.
165  
183   
185   
189   
193   
194 0.15  Added the possibility for macro tags to suppress swallow the following line
195      Control tags like if, else, elseif, end, foreach, set and comments    
196      (<%-- --%>) automatically suppress swallow the following line seperator.
201   
204   
206   
207 0.11  Replaced all the dirty hacks for keeping track of template line numbers    
211   
214   
217   
223   
229   
232   

Version 53 by Lehni on 16. April 2007, 18:35

101  <% foreach $item in param.list %>
102       <%= $item#index %>
103       <%= $item#length %>
104       <%= $item#isFirst %>
105       <%= $item#isLast %>
106  <% end %>
149  <% do_something macro_call default=$text %>

Version 52 by Lehni on 16. April 2007, 18:32

38* Loop variables give access to the state of the loop: $variable#isFirst, #isLast, #index, #length.
92During every for loop these helper variables are available:
93
94  $variable#index // Index of the current iteration
95  $variable#length // Length of the entire for loop
96  $variable#isFirst // Is this the first iteration?
97  $variable#isLast // Is this the last iternation?
98
99E.g.:
100
101<% foreach $item in param.list %>
102 <%= $item#index %>
103 <%= $item#length %>
104 <%= $item#isFirst %>
105 <%= $item#isLast %>
106<% end %>
107
128=====Sub Templates Variables
129
140A tag ending with -%> is trimmed after rendering, so that an empty template really
141results in an empty string:
142
143  <% $empty -%>
144
143 0.23  Added loop variables: $variable#index, #length, #isFirst, #isLast.
144      Many bug fixes.
145  

Version 51 by Lehni on 14. April 2007, 21:09

91=====Swallow CR LF after tagsLine Breaks
134  
144  
149  
152  
155  
157  
161  
165  
170  
175  
178  
180  
186  
189  
192  
198  
204  
207  

Version 50 by Lehni on 14. April 2007, 21:06

41=====Conditional statements, expressions:
59=====Loops:Loops
91=====Swallow CR LF after tags:tags
102=====Sub Templates:Templates
137====Revisions:Revisions
144 
149 
152 
155 
157 
161 
165 
170 
175 
178 
180 
186 
189 
192 
198 
204 
207 

Version 49 by Lehni on 14. April 2007, 21:05

41=====Conditional statements, expressions:
59=====Loops:
91=====Swallow CR LF after tags:
102=====Sub Templates:

Version 48 by Lehni on 14. April 2007, 21:04

13The file needs to be placed in the global protoype, it adds one function to the HopObject prototype:====Helma Integration
15<tt>HopObjectTemplate.renderTemplate(name, param, out)</tt>js needs to be placed in the global protoype.
16It adds the function renderTemplate() to the HopObject prototype, that can be then called on any HopObject.
17* name is the name of the skin<tt>HopObject.prototype.renderTemplate(name, without the extension. "jstl" is used as extension for the template filesparam, which stands for "JavaScript Template Language".out)</tt>
18* param is the optional parameter, which can be accessed from the templates, just like in Helma skins.
19* out is the writer object where the whole template is written to. if none is specified, renderTemplate renders into a StringBuffer and returns its value as a string.
19* <tt>name</tt> is the name of the skin, without the extension. "jstl" is used as extension for the template files, which stands for "JavaScript Template Language".
20* <tt>param</tt> is the optional parameter, which can be accessed from the templates, just like in Helma skins.
21* <tt>out</tt> is the writer object where the whole template is written to. if none is specified, renderTemplate renders into a StringBuffer and returns its value as a string.
22
51Result:
52
53  Hello World
54
80Results in: [1, 2, 3]Result:
82====  [1, 2, 3]
91Resulting in:Result:

Version 47 by Lehni on 14. April 2007, 21:00

13 Revisions:
14     
15 0.22  More clean-ups in macro parsing code, distinction between control tags
16      and macro tags is now only on the handling level, not parsing level.
17      This adds feature like prefix / suffix to foreach and if / elseif, and
18      resulted in cleaner code.
19      Additionally, the separator parameter can now be set in foreach.
20    
21 0.21  Major rewrite and refactoring of most parts, adaption of Hannes' latest
22      additions to Helma skins (sub templates, nested macros, filters),
23      varios design changes (e.g. only allow to define and set $-variables for
24      inside templates).
25    
26 0.20  Refactored the code rendering code to be more readibly and smaller.
27      Removed Helma dependency, by using preprocessing macros.
28    
29 0.19  Added support for sub templates and a special macro
30      for both rendering sub templates and external templates.
31    
32 0.18  Added support for encoding parameter, fixed a bug in <% else %>
33    
34 0.17  Many clean-ups and simplifications of regular expressions and parsing.
35      At parsing time, no code is evaluated any longer, except the final
36      result. This leads to further speed improvements by about 1.5.
37    
38 0.16  Fixed issues with the display of errors. The correct line numbers
39      should be reported now. If a macro call results in an exception
40      The exception is caught and repported just like in Helma skins now.
41    
42 0.15  Added the possibility for macro tags to suppress the following line
43      separator, if there is any, by adding a minus at the end: <% macro -%>.
44      Control tags like if, else, elseif, end, foreach, set and comments   
45      (<%-- --%>) automatically suppress the following line seperator.
46    
47 0.14  Added support for res.handlers.
48      Switched to java.util.regex for the tag parser.
49      Fixed a bug with escaped quotes in macro parameters.
50      Reformated template generating code to be more readable.
51    
52 0.13  Added support for properties in <% %>-tags (not only macros)
53      and fixed an incompatibility with the Rhino Debugger and jstl templates.
54    
55 0.12  Fixed various bugs that were introduced in the 0.11 rewrite.
56    
57 0.11  Replaced all the dirty hacks for keeping track of template line numbers   
58      and linking them to code line numbers by a clean implementation of the
59      same functionality.
60      The result is a faster and less resource hungry parser.
61      Cleaned up the code, seperated tag parser form line parser.
62    
63 0.10  More speed improvements, parsing is now around 6-7 times faster
64      than in 0.8
65    
66 0.9  Various speed improvements, leading to an overall decrease of parsing
67      time by more than factor 3.
68    
69 0.8  Added support for HopObject collections in foreach
70      Removed regexp filter for if() expressions that sometimes seemed
71      to deadlock
72      Fixed a bug with finding the right template in the inheritance chain
73      if it was overriden by another one.
74    
75 0.7  Fixed problems with error reports. Full stacktraces are now printed,
76      and errors caused in macros called from the template are now properly
77      detected and reported.
78      Switched to using Context.evaluateString() instead of eval(),
79      for improve of speed and reception of proper exceptions.
80    
81 0.6  fixed a bug that caused macros in  objects other than 'this' and
82      'root' to fail.
83    
84 0.5  first public release.
85
31====Features
32
33* Macros with conditional statements and loops can define prefix, suffix default and encoding parameters too.
34* Loops can define an additional paraemter called separator, which will be added between entries, but only if there was output.
35* Any macro that ends with -%&gt; swallows the following line break.
36
42Conditional statements support prefix, suffix and default:
43
44  <% if param.greetings prefix="Hello" %>
45    World
46  <% end %>
47
65Loops support prefix, suffix, default and separator:
66
67  <% foreach $value in [1, 2, 3] prefix="[ " suffix=" ]" separator=", " %>
68      <%= $value %>
69  <% end %>
70
71Results in: [1, 2, 3]
72
73====
74
111
112====Revisions:
113
114 0.22  More clean-ups in macro parsing code, distinction between control tags
115      and macro tags is now only on the handling level, not parsing level.
116      This adds feature like prefix / suffix to foreach and if / elseif, and
117      resulted in cleaner code.
118      Additionally, the separator parameter can now be set in foreach.
119
120 0.21  Major rewrite and refactoring of most parts, adaption of Hannes' latest
121      additions to Helma skins (sub templates, nested macros, filters),
122      varios design changes (e.g. only allow to define and set $-variables for
123      inside templates).
124
125 0.20  Refactored the code rendering code to be more readibly and smaller.
126      Removed Helma dependency, by using preprocessing macros.
127
128 0.19  Added support for sub templates and a special macro
129      for both rendering sub templates and external templates.
130
131 0.18  Added support for encoding parameter, fixed a bug in <% else %>
132
133 0.17  Many clean-ups and simplifications of regular expressions and parsing.
134      At parsing time, no code is evaluated any longer, except the final
135      result. This leads to further speed improvements by about 1.5.
136
137 0.16  Fixed issues with the display of errors. The correct line numbers
138      should be reported now. If a macro call results in an exception
139      The exception is caught and repported just like in Helma skins now.
140
141 0.15  Added the possibility for macro tags to suppress the following line
142      separator, if there is any, by adding a minus at the end: <% macro -%>.
143      Control tags like if, else, elseif, end, foreach, set and comments   
144      (<%-- --%>) automatically suppress the following line seperator.
145
146 0.14  Added support for res.handlers.
147      Switched to java.util.regex for the tag parser.
148      Fixed a bug with escaped quotes in macro parameters.
149      Reformated template generating code to be more readable.
150
151 0.13  Added support for properties in <% %>-tags (not only macros)
152      and fixed an incompatibility with the Rhino Debugger and jstl templates.
153
154 0.12  Fixed various bugs that were introduced in the 0.11 rewrite.
155
156 0.11  Replaced all the dirty hacks for keeping track of template line numbers   
157      and linking them to code line numbers by a clean implementation of the
158      same functionality.
159      The result is a faster and less resource hungry parser.
160      Cleaned up the code, seperated tag parser form line parser.
161
162 0.10  More speed improvements, parsing is now around 6-7 times faster
163      than in 0.8
164
165 0.9  Various speed improvements, leading to an overall decrease of parsing
166      time by more than factor 3.
167
168 0.8  Added support for HopObject collections in foreach
169      Removed regexp filter for if() expressions that sometimes seemed
170      to deadlock
171      Fixed a bug with finding the right template in the inheritance chain
172      if it was overriden by another one.
173
174 0.7  Fixed problems with error reports. Full stacktraces are now printed,
175      and errors caused in macros called from the template are now properly
176      detected and reported.
177      Switched to using Context.evaluateString() instead of eval(),
178      for improve of speed and reception of proper exceptions.
179
180 0.6  fixed a bug that caused macros in  objects other than 'this' and
181      'root' to fail.
182
183 0.5  first public release.
184

Version 46 by Lehni on 14. April 2007, 20:49

101* <tt>&lt;%= param.object.href() %&gt;</tt>: prints out the value or the result of a function call. response, request, session do NOT yet link to res.data, req.data, session.data.
107  <% if (sessionsession.user != null) null %>

Version 45 by Lehni on 14. April 2007, 20:48

15 0.22  More clean-ups in macro parsing code, distinction between control tags
16      and macro tags is now only on the handling level, not parsing level.
17      This adds feature like prefix / suffix to foreach and if / elseif, and
18      resulted in cleaner code.
19      Additionally, the separator parameter can now be set in foreach.
20    
91* <tt>&lt;% foreach ($object $object in list) list %&gt; ... &lt;% end %&gt;</tt>: loops over the list, on purpose not named "for ($object in list)", because object won't be the index but the object itself
92* <tt>&lt;% if () ... %&gt;, &lt;% elseif () ... %&gt;, &lt;% else %&gt;, &lt;% end %&gt;</tt>
110  <% foreach ($topic $topic in param.topics) topic %>
116      <% if ($count $count == 1) 1 %>
118      <% elseif ($count $count > 1) 1 %>

Version 44 by Lehni on 13. April 2007, 18:51

94* <tt>&lt;% macro &gt;nested content&lt;/%&gt;</tt>: passes the nested content to the macro, as a second parameter.
143The implementation of sub templates has changed a lot to reflect the new skin features outlined here. Sub template are to be added at the end of files:
144Sub template are to be added at the end of files:

Version 43 by Lehni on 13. April 2007, 18:50

132Any tag can end with -%> to indicated that it does not want the new line afterafter it beig being rendered. By default. All the control macros do so by default:
133it beig being rendered. By default. All the control macros do so by default:
143The implementation of sub templates has change changed a lot to reflect the new skinskin features outlined here. Sub template are to be added at the end of files:
144features outlined here. Sub template are to be added at the end of files:
169These can then be used like normal variables, and for example be passed asas the default value in another macro. Note that althought the definition is at the end, the variable is valid in the whole scope.
170the default value in another macro. Note that althought the definition is at the end, the variable is valid in the whole scope.

Version 42 by Lehni on 13. April 2007, 18:49

171This These can then be used like a normal variablevariables, and for example be passed as
172the default value in another macro:macro. Note that althought the definition is at the end, the variable is valid in the whole scope.

Version 41 by Lehni on 13. April 2007, 18:14

9Due to all these changes, I have decided to keep the last revision before the changes here (Template-20.js). Also, I uploaded the unprocessed file for those interested in seeing how I am using the cpp preprocessor from gcc among with stripjsjsstrip.py and sed to produce the final files. I will write more about this soon.

Version 40 by Lehni on 13. April 2007, 18:13

9Due to all these changes, I have decided to keep the last revision before the changes here (Template-20.js). Also, I uploaded the unprocessed file for those interested in seeing how I am using the cpp preprocessor from gcc among with stripjs.py and sed to produce the final files. I will write more about this soon.
10

Version 39 by Lehni on 13. April 2007, 18:07

12      
17     
20     
23     
25     
29     
33     
36      Control tags like if, else, elseif, end, foreach, set and comments comments   
38     
43     
46     
48     
49 0.11  Replaced all the dirty hacks for keeping track of template line numbers numbers   
53     
56     
59     
65     
71     
74     
119       

Version 38 by Lehni on 13. April 2007, 18:07

12   
17  
20  
23  
25  
29  
33  
36      Control tags like if, else, elseif, end, foreach, set and comments comments 
38  
43  
46  
48  
49 0.11  Replaced all the dirty hacks for keeping track of template line numbers numbers 
53  
56  
59  
65  
71  
74  
119          

Version 37 by Lehni on 13. April 2007, 18:04

17 
20 
38 
91* <tt>&lt;% macro foo="bar" array=[1,2,3] hash={a:1, b: 2, c:3} nested=<% &lt;% param.value %> %&gt; | filter param="string" %&gt;</tt>: calls the macro. Supported are: Global macros, object  macros and res.handlers (e.g. this.macro, root.macro, etc.); prefix, suffix, default, encoding parameters; Neted macros; Filter chains. This is supposed to be fully backward compatible with Helma 1 skins.
127
128====Swallow CR LF after tags:
129
130Any tag can end with -%> to indicated that it does not want the new line after
131it beig being rendered. By default. All the control macros do so by default:
132
133  <%= "Hel" -%>
134  <%= "ma" %>
135
136Resulting in:
137
138  Helma

Version 36 by Lehni on 13. April 2007, 18:00

7With revision 0.21 came many changes that reflect the recent *addition of new skin features in Helma 1.6|http://dev.helma.org/wiki/New+Skin+Features+in+Helma+1.6/*.
8
12 0.21  Major rewrite and refactoring of most parts, adaption of Hannes' latest
13      additions to Helma skins (sub templates, nested macros, filters),
14      varios design changes (e.g. only allow to define and set $-variables for
15      inside templates).
16
17 0.20  Refactored the code rendering code to be more readibly and smaller.
18      Removed Helma dependency, by using preprocessing macros.
19
30 
43      same functionality. The result is a faster and less resource hungry parser.
44      The result is a faster and less resource hungry parser.
46 0.10  More speed improvements, parsing is now around 6-7 times faster than in 0.faster
47      than in 0.8
48 0.9  Various speed improvements, leading to an overall decrease of parsing timeparsing
49       time by more than factor 3.
51      Removed regexp filter for if() expressions that sometimes seemed to deadlockseemed
52       Fixed a bug with finding the right template in the inheritance chain if itto deadlock
53       was overriden by another one.Fixed a bug with finding the right template in the inheritance chain
54      if it was overriden by another one.
53 0.7  Fixed problems with error reports. Full stacktraces are now printed, and errors
54       and errors caused in macros called from the template are now properly detected and reported.properly
55       Switched to using Contextdetected and reported.evaluateString() instead of eval(), for improve of speed
56       and reception of proper exceptionsSwitched to using Context.evaluateString() instead of eval(),
57      for improve of speed and reception of proper exceptions.
55 0.6  fixed a bug that caused macros in  objects other than 'this' and 'root' to fail.and
56      'root' to fail.
69* <tt>&lt;% foreach (object ($object in list) %&gt; ... &lt;% end %&gt;</tt>: loops over the list, on purpose not named "for (object ($object in list)", because object won't be the index but the object itself
71* <tt>&lt;% set variable $variable = otherVariable [ + some arithmetic ] %&gt;,</tt> e.g. <tt>&lt;% set count $count = this.nodes.count() %&gt;</tt>
72* <tt>&lt;% macro foo="bar" array=[1,2,3] hash={a:1, b: 2, c:3} nested=<% param.value %> | filter param="string" %&gt;</tt>: calls the macro. Supported are: Global macros, both global macros and object based  macros are supported and res.handlers (e.g. this.macro, root.macro, etc.). ); prefix, suffix, default are supporteddefault, encoding parameters; Neted macros; Filter chains. It This is supposed to be fully backward compatible with Helma 1 skins.
73* <tt>&lt;% param.value %&gt;</tt>: prints out the value, response, request, sesion, param are suppored, as links to res.data, req.data, session.data, param. Filters, parameters and nested macros work just as in macro calls. This is here mostly for backward compatibility. The prefered and faster way of printing simple data is:
74* <tt>&lt;%= param.object.href() %&gt;</tt>: prints out the value or the result of a function call. response, request, session do NOT yet link to res.data, req.data, session.data.
88  <% foreach (topic ($topic in param.topics) %>
90      <td><%= topic$topic.renderLink() %></td>
91      <td><%= topic$topic.creator.renderLink() %></td>
92      <% set count $count = topic.comments.count() - 1 %>
93      <% if (count ($count == 1) %>
94      <% elseif (count ($count > 1) %>
95        <%= count $count %> Posts
99      <td nowrap><%= topic$topic.createDate.format(createDate | format "dd.MM.yy - HH:mm")  %></td>
106The implementation of sub templates has change a lot to reflect the new skin
107features outlined here. Sub template are to be added at the end of files:
108http://dev.helma.org/wiki/New+Skin+Features+in+Helma+1.6/
109
109  <% template "name"#name %>
111  </%>Empty lines before and after it are automatically removed.
113  <% #greedy +%>
114  This is another sub-template. As apposed to the other one, this one keeps the
115  empty lines due to the +.
116
116  <% render this.template "name#name" value="variables" %>
120  <% this.render template "name" foo="bar" %>
122Definition of a template and rendering into a scope variable in one command:
124  <% set "text"$text %>
125  Render this text into 'text$text'. Again, <% macros %> can be called.
126  </%>
126This can now then be used like a normal variable, and for example be passed as
129  <%= text $text %>
131  <% do_something default=text $text %>

Version 35 by zumbrunn on 02. March 2007, 03:13

7*Download|http://dev<% this.helma.org/static/helma.dev/wiki/JavaScript%20Template%20Engine/Template.js*attachments %>

Version 34 by zumbrunn on 15. February 2007, 09:23

7*Download|http://dev.helma.org/static/helma.dev/Wiki/JavaScript%20Template%20Engine/Templatedev/wiki/JavaScript%20Template%20Engine/Template.js*

Version 33 by Lehni on 08. November 2006, 11:46

11 0.18  Added support for encoding parameter, fixed a bug in <% else %>
12 
14 
15 0.18  Added support for encoding parameter, fixed a bug in <% else %>

Version 32 by Lehni on 08. November 2006, 02:32

132  Render this text into 'nametext'. <% macros %> can be called.

Version 31 by Lehni on 08. November 2006, 02:19

83=====Conditional statements, expressions:
91=====Loops:
113=====Sub Templates:

Version 30 by Lehni on 08. November 2006, 02:18

117  <% template "name"
118  This is a sub-template. It can call <% macros %> and write <%= param.value %> too!
119  </%>
121  <% render "name" value="variables" %>
125  <% this.render "name" foo="bar" %>
129  <% set "text"
130  Render this text into 'name'. <% macros %> can be called.
131  </%>
134  <%= text %>
136  <% do_something default=text %>

Version 29 by Lehni on 08. November 2006, 02:18

15 
83=====Conditional statements, expressions:
91=====Loops:
112
113=====Sub Templates:
114
115Definition:
116
117<% template "name">
118This is a sub-template. It can call <% macros %> and write <%= param.value %> too!
119</%>
120
121Rendering:
122
123<% render "name" value="variables" %>
124
125Rendering of normal templates:
126
127<% this.render "name" foo="bar" %>
128
129Definition and rendering into a variable in one command:
130
131<% set "text">
132Render this text into 'name'. <% macros %> can be called.
133</%>
134
135This can now be used like a normal variable, and for example be passed as
136the default value in another macro:
137
138<%= text %>
139
140<% do_something default=text %>

Version 28 by Lehni on 08. November 2006, 02:12

13 0.19  Added support for sub templates and a special macro
14      for both rendering sub templates and external templates.
15

Version 27 by Lehni on 07. November 2006, 02:34

10  
11 0.18  Added support for encoding parameter, fixed a bug in <% else %>

Version 26 by Lehni on 04. November 2006, 01:28

12       At parsing time, no code is evaluated any longer, except the final

Version 25 by Lehni on 04. November 2006, 01:27

11 0.17  Many clean-ups and simplifications of regular expressions and parsing.
12     At parsing time, no code is evaluated any longer, except the final
13      result. This leads to further speed improvements by about 1.5.
14 

Version 24 by hannes on 31. October 2006, 10:41

64* <tt><% <tt>&lt;% foreach (object in list) %> %&gt; ... <% &lt;% end %></tt>: %&gt;</tt>: loops over the list, on purpose not named "for (object in list)", because object won't be the index but the object itself
65* <tt><% <tt>&lt;% if () %>%&gt;, <% &lt;% elseif () %>%&gt;, <% &lt;% else %>%&gt;, <% &lt;% end %></tt>%&gt;</tt>
66* <tt><% <tt>&lt;% set variable = otherVariable [ + some arithmetic ] %>%&gt;,</tt> e.g. <tt><% <tt>&lt;% set count = this.nodes.count() %></tt>%&gt;</tt>
67* <tt><% <tt>&lt;% macro foo="bar" array=[1,2,3] hash={a:1, b: 2, c:3} %></tt>: %&gt;</tt>: calls the macro, both global macros and object based macros are supported (e.g. this.macro, root.macro, etc.). prefix, suffix, default are supported. It is supposed to be fully backward compatible with Helma 1 skins.
68* <tt><% <tt>&lt;% macro >nested content</%></tt>: &gt;nested content&lt;/%&gt;</tt>: passes the nested content to the macro, as a second parameter.
69* <tt><% <tt>&lt;% param.value %></tt>: %&gt;</tt>: prints out the value, response, request, sesion, param are suppored, as links to res.data, req.data, session.data, param. This is here for backward compatibility. The prefered way of printing data is:
70* <tt><%<tt>&lt;%= param.object.href() %></tt>: %&gt;</tt>: prints out the value or the result of a function call. response, request, session do NOT link res.data, req.data, session.data.
90          

Version 23 by Lehni on 27. October 2006, 13:00

10  
11 0.16  Fixed issues with the display of errors. The correct line numbers
12      should be reported now. If a macro call results in an exception
13      The exception is caught and repported just like in Helma skins now.
14 
60* <tt>&lt;% <tt><% foreach (object in list) %&gt; %> ... &lt;% <% end %&gt;</tt>: %></tt>: loops over the list, on purpose not named "for (object in list)", because object won't be the index but the object itself
61* <tt>&lt;% <tt><% if () %&gt;%>, &lt;% <% elseif () %&gt;%>, &lt;% <% else %&gt;%>, &lt;% <% end %&gt;</tt>%></tt>
62* <tt>&lt;% <tt><% set variable = otherVariable [ + some arithmetic ] %&gt;%>,</tt> e.g. <tt>&lt;% <tt><% set count = this.nodes.count() %&gt;</tt>%></tt>
63* <tt>&lt;% <tt><% macro foo="bar" array=[1,2,3] hash={a:1, b: 2, c:3} %&gt;</tt>: %></tt>: calls the macro, both global macros and object based macros are supported (e.g. this.macro, root.macro, etc.). prefix, suffix, default are supported. It is supposed to be fully backward compatible with Helma 1 skins.
64* <tt>&lt;% <tt><% macro &gt;nested content&lt;/%&gt;</tt>: >nested content</%></tt>: passes the nested content to the macro, as a second parameter.
65* <tt>&lt;% <tt><% param.value %&gt;</tt>: %></tt>: prints out the value, response, request, sesion, param are suppored, as links to res.data, req.data, session.data, param. This is here for backward compatibility. The prefered way of printing data is:
66* <tt>&lt;%<tt><%= param.object.href() %&gt;</tt>: %></tt>: prints out the value or the result of a function call. response, request, session do NOT link res.data, req.data, session.data.
86        &nbsp; 

Version 22 by Lehni on 21. June 2006, 11:38

15 

Version 21 by Lehni on 21. June 2006, 11:37

11 0.15  Added the possibility for macro tags to suppress the following line
12      separator, if there is any, by adding a minus at the end: <% macro -%>.
13      Control tags like if, else, elseif, end, foreach, set and comments
14      (<%-- --%>) automatically suppress the following line seperator.
15

Version 20 by Lehni on 21. June 2006, 10:26

10  
11 0.14  Added support for res.handlers.
12      Switched to java.util.regex for the tag parser.
13      Fixed a bug with escaped quotes in macro parameters.
14      Reformated template generating code to be more readable.

Version 19 by Lehni on 16. June 2006, 14:52

11 0.13  Added support for properties in <% %>-tags (not only macros).
12      and fixed an incompatibility with the Rhino Debugger and jstl templates.

Version 18 by Lehni on 16. June 2006, 14:03

7*Download|http://dev.helma.org/static/helma.dev/Wiki/JavaScript%20Template%20Engine/templatedev/Wiki/JavaScript%20Template%20Engine/Template.js*

Version 17 by Lehni on 16. June 2006, 14:01

10 
14 

Version 16 by Lehni on 16. June 2006, 14:01

10
11 0.13  Added support for properties in <% %>-tags (not only macros).
13 
22      by more than factor 3.

Version 15 by Lehni on 08. May 2006, 22:51

7*Download|http://dev.helma.org/static/helma.dev/Wiki/JavaScript%20Template%20Engine/Templatedev/Wiki/JavaScript%20Template%20Engine/template.js*

Version 14 by Lehni on 08. May 2006, 22:49

11 0.12  Fixed various bugs that were introduced in the 0.11 rewrite.
12 

Version 13 by Lehni on 31. March 2006, 19:25

15 

Version 12 by Lehni on 31. March 2006, 19:25

11 0.11  Replaced all the dirty hacks for keeping track of template line numbers
12      and linking them to code line numbers by a clean implementation of the
13      same functionality. The result is a faster and less resource hungry parser.
14      Cleaned up the code, seperated tag parser form line parser.
15

Version 11 by Lehni on 30. March 2006, 16:07

9==== Revisions:

Version 10 by Lehni on 30. March 2006, 16:06

10
11 0.9  Various speed improvements, leading to an overall decrease of parsing time
12      by more than factor 3
12 0.8 10  Added support for HopObject collections More speed improvements, parsing is now around 6-7 times faster than in foreach0.
13      Removed regexp filter for if() expressions that sometimes seemed to deadlock
14      Fixed a bug with finding the right template in the inheritance chain if it
15      was overriden by another one.
14 0.7 9  Fixed problems with error reports. Full stacktraces are now printedVarious speed improvements, and errorsleading to an overall decrease of parsing time
15      caused in macros called from the template are now properly detected and reported. by more than factor
16      Switched to using Context.evaluateString() instead of eval(), for improve of speed
17      and reception of proper exceptions.
18 0.6  fixed a bug that caused macros in  objects other than 'this' and 'root' to fail.
16 0.5 8  first public release. Added support for HopObject collections in foreach
17      Removed regexp filter for if() expressions that sometimes seemed to deadlock
18      Fixed a bug with finding the right template in the inheritance chain if it
19      was overriden by another one.
20 
21 0.7  Fixed problems with error reports. Full stacktraces are now printed, and errors
22      caused in macros called from the template are now properly detected and reported.
23      Switched to using Context.evaluateString() instead of eval(), for improve of speed
24      and reception of proper exceptions.
25 
26 0.6  fixed a bug that caused macros in  objects other than 'this' and 'root' to fail.
27 
28 0.5  first public release.

Version 9 by Lehni on 29. March 2006, 16:58

10
11 0.9  Various speed improvements, leading to an overall decrease of parsing time
12      by more than factor 3
13 
13      Fixed a bug with finding the right template in the inheritance chain if it was overridenit
14      was overriden by another one.
15 0.7  Fixed problems with error reports. Full stacktraces are now printed, and errors caused
16 0.7  Fixed problems with error reports.   in macros called from the template Full stacktraces are now properly detected printed, and reported.errors
17      caused in macros called from the template are now properly detected and reported.
17 

Version 8 by Lehni on 25. March 2006, 06:52

14
19
21

Version 7 by Lehni on 25. March 2006, 06:52

9==== Revisions:
10 0.8  Added support for HopObject collections in foreach
11      Removed regexp filter for if() expressions that sometimes seemed to deadlock
12      Fixed a bug with finding the right template in the inheritance chain if it was overriden
13      by another one.
14
14 
15 0.6  fixed a bug that caused macros in  objects other than 'this' and 'root' to fail.
16 

Version 6 by Lehni on 19. March 2006, 05:07

13      and reception of proper exceptions.
15 0.6  fixed a bug that caused macros in other objects other than 'this' and 'root' to fail.
17 0.5  first public release.

Version 5 by Lehni on 19. March 2006, 05:05

8 Revisions:
9 ====Revisions:

Version 4 by Lehni on 19. March 2006, 05:04

9 
14 
16 
18

Version 3 by Lehni on 19. March 2006, 05:04

8 Revisions:
9
10 0.7  Fixed problems with error reports. Full stacktraces are now printed, and errors caused
11      in macros called from the template are now properly detected and reported.
12      Switched to using Context.evaluateString() instead of eval(), for improve of speed
13      and reception of proper exceptions
14
15 0.6  fixed a bug that caused macros in other objects than 'this' and 'root' to fail
16
17 0.5  first public release
18

Version 2 by Lehni on 19. March 2006, 04:56

7*Download|http://dev.helma.org/static/helma.dev/Wiki/Helma%202%20Templates%20-%20juerg/Templatedev/Wiki/JavaScript%20Template%20Engine/Template.js*

Version 1 by Lehni on 19. March 2006, 04:54

1Read *Helma 2 Templates - juerg* for a short overview of my efforts towards a more flexible templating engine in Helma (2).
3The JavaScript Tempalte Engine is implemented in Helma 1.5, not Helma 2, but functions as a testcase for exploration of concepts for future releases. This doesn't stop me from using it in real websites as well, and so far it is working very well for me. It actually took away the urge to solve the problem.
4
5The implementation is based on my comments in *06-12-05|http://helma.org/pipermail/helma-dev/2005-December/002461.html*. As far as I know, the implementation is fully backward compatible with Helma 1 skins and macros.
6
7*Download|http://dev.helma.org/static/helma.dev/Wiki/Helma%202%20Templates%20-%20juerg/Template.js*
8
9The file needs to be placed in the global protoype, it adds one function to the HopObject prototype:
10
11<tt>HopObject.renderTemplate(name, param, out)</tt>
12
13* name is the name of the skin, without the extension. "jstl" is used as extension for the template files, which stands for "JavaScript Template Language".
14* param is the optional parameter, which can be accessed from the templates, just like in Helma skins.
15* out is the writer object where the whole template is written to. if none is specified, renderTemplate renders into a StringBuffer and returns its value as a string.
16
17====Overview of Statements
18
19* <tt>&lt;% foreach (object in list) %&gt; ... &lt;% end %&gt;</tt>: loops over the list, on purpose not named "for (object in list)", because object won't be the index but the object itself
20* <tt>&lt;% if () %&gt;, &lt;% elseif () %&gt;, &lt;% else %&gt;, &lt;% end %&gt;</tt>
21* <tt>&lt;% set variable = otherVariable [ + some arithmetic ] %&gt;,</tt> e.g. <tt>&lt;% set count = this.nodes.count() %&gt;</tt>
22* <tt>&lt;% macro foo="bar" array=[1,2,3] hash={a:1, b: 2, c:3} %&gt;</tt>: calls the macro, both global macros and object based macros are supported (e.g. this.macro, root.macro, etc.). prefix, suffix, default are supported. It is supposed to be fully backward compatible with Helma 1 skins.
23* <tt>&lt;% macro &gt;nested content&lt;/%&gt;</tt>: passes the nested content to the macro, as a second parameter.
24* <tt>&lt;% param.value %&gt;</tt>: prints out the value, response, request, sesion, param are suppored, as links to res.data, req.data, session.data, param. This is here for backward compatibility. The prefered way of printing data is:
25* <tt>&lt;%= param.object.href() %&gt;</tt>: prints out the value or the result of a function call. response, request, session do NOT link res.data, req.data, session.data.
26
27====Examples
28
29Conditional statements, expressions:
30
31  <% if (session.user != null) %>
32    Hello <%= session.user.name %>
33  <% else %>
34    <a href="/login">Login</a>
35  <% end %>
36
37Loops:
38
39  <table>
40  <% foreach (topic in param.topics) %>
41    <tr class="topic">
42      <td><%= topic.renderLink() %></td>
43      <td><%= topic.creator.renderLink() %></td>
44      <td>
45      <% set count = topic.comments.count() - 1 %>
46      <% if (count == 1) %>
47        1 Post
48      <% elseif (count > 1) %>
49        <%= count %> Posts
50      <% else %>
51        &nbsp;
52      <% end %>
53      </td>
54      <td nowrap><%= topic.createDate.format("dd.MM.yy - HH:mm") %></td>
55    </tr>
56  <% end %>
57  </table>