Helma Logo
main list history

Version 14 by michi on 08. December 2005, 18:53

5  <h1><hc:this.msg id="site.topics.header">All topics</hc:this.msg></h1>
6  <p><hc:this.topics.count>
7    <ha:0><hc:this.msg id="site.topics.noTopics" /></ha:0>
8    <ha:1><hc:this.msg id="site.topics.oneTopic" /></ha:1>
9    <ha:n><hc:this.msg id="site.topics.moreTopics" /></ha:n>
10  </hc:this.topics.count></p>
11  <hc:site.loop alternate="2">
12    <ha:prefix>
13    <table>
14      <tr>
15        <th><hc:this.msg id="site.topics.tableHead.topic" /></th>
16        <th><hc:this.msg id="site.topics.tableHead.numberOfStories" /></th>
17      </tr>
18    </ha:prefix>
19    <ha:body>
20      <tr class="row<hc:param.alternateCnt />">
21        <td><hc:topic.name /></td>
22        <td><hc:topic.count /></td>
23      </tr>
24    </ha:body>
25    <ha:suffix>
26    </table>
27    </h:suffix>
28  </hc:site.loop>
29
42
43
44  <h1><hc:this.msg id="site.topics.header">All topics</hc:this.msg></h1>
45  <p><hc:this.topics.count>
46    <ha:0><hc:this.msg id="site.topics.noTopics" /></ha:0>
47    <ha:1><hc:this.msg id="site.topics.oneTopic" /></ha:1>
48    <ha:n><hc:this.msg id="site.topics.moreTopics" /></ha:n>
49  </hc:this.topics.count></p>
50  <hc:site.loop alternate="2">
51    <ha:prefix>
52    <table>
53      <tr>
54        <th><hc:this.msg id="site.topics.tableHead.topic" /></th>
55        <th><hc:this.msg id="site.topics.tableHead.numberOfStories" /></th>
56      </tr>
57    </ha:prefix>
58    <ha:body>
59      <tr class="row<hc:param.alternateCnt />">
60        <td><hc:topic.name /></td>
61        <td><hc:topic.count /></td>
62      </tr>
63    </ha:body>
64    <ha:suffix>
65    </table>
66    </h:suffix>
67  </hc:site.loop>

Version 13 by michi on 08. December 2005, 18:52

42
45    <ha:0><hc:this.msg id="site.topics.noTopics">No topics to display.</hc:this.msg></ha:0> /></ha:0>
46    <ha:1><hc:this.msg id="site.topics.oneTopic">This site has just one topic.</hc:this.msg></ha:1> /></ha:1>
47    <ha:n><hc:this.msg id="site.topics.moreTopics">This site has <hc:this.count /> topics.</hc:this.msg></ha:n> /></ha:n>
51        <th><hc:this.msg id="site.topics.tableHead.topic">Topic</hc:this.msg></th> /></th>
52        <th><hc:this.msg id="site.topics.tableHead.numberOfStories">Number of Stories</hc:this.msg></th> /></th>

Version 12 by michi on 08. December 2005, 18:51

3* follow february-proposal, starting with andreas <a href=My current code snippet that tries to implement the ideas of the "http://helma.org/pipermail/helma-dev/2005-February/001714.html">code snippet</a> from back then'feburary-proposal'
4* allow walking through object-structure (not really necessary, since this could be implemented by passing along a parameter to the macro, but a 'this.topics.count' is definitely prefered to 'this.count collection="topics"'
5* either use <code><% .. %></code> or <h:macro .. />, but dont allow both
6* XHTML conformance of the templates is an absolut non-goal for me. i just dont see a reason for that. Additionally macros are inserted not just outside of tags, but also within e.g. a style-attribute of a tag. The <h:macro .. />-syntax there breaks xml-conformance anyways.
7* <h:macro call="param.i" /> just seems to be an overkill for what has been <code><% param.i %></code> before
8* I consider pushing information to skins via the param-object resp response-object not desirable, since these parameters are hard to document for template designers.
9* keep it simple, and avoid magic, non-intuitive behavior
10* a goal should be, that "inline-skins" can easily be extracted into separate skins at a later point
5My current code snippet:
6
71
72* follow february-proposal, starting with andreas <a href="http://helma.org/pipermail/helma-dev/2005-February/001714.html">code snippet</a> from back then
73* allow walking through object-structure (not really necessary, since this could be implemented by passing along a parameter to the macro, but a 'this.topics.count' is definitely prefered to 'this.count collection="topics"'
74* either use <code><% .. %></code> or <h:macro .. />, but dont allow both
75* XHTML conformance of the templates is an absolut non-goal for me. i just dont see a reason for that. Additionally macros are inserted not just outside of tags, but also within e.g. a style-attribute of a tag. The <h:macro .. />-syntax there breaks xml-conformance anyways.
76* <h:macro call="param.i" /> just seems to be an overkill for what has been <code><% param.i %></code> before
77* I consider pushing information to skins via the param-object resp response-object not desirable, since these parameters are hard to document for template designers.
78* keep it simple, and avoid magic, non-intuitive behavior
79* a goal should be, that "inline-skins" can easily be extracted into separate skins at a later point

Version 11 by michi on 07. December 2005, 11:26

10* a goal should be, that "inline-skins" can easily be extracted into separate skins at a later point

Version 10 by michi on 07. December 2005, 11:23

42    this.renderSkin(createSkin(getText(param.id)));

Version 9 by michi on 07. December 2005, 11:20

75<b>Explanation</b>: What has been before <code><% this.hello key1="value01" %></code>, is now <code><hc:this.hello key1="value01" /></code>, which is nothing but a transformation of syntax. The <b>only</b> difference now is, that additional parameters to the macro can be specified by embedding ha-tags into the hc-tag. (hc stands for helma-call, and ha for helma-argument, whereas i'm open for better names)

Version 8 by michi on 07. December 2005, 11:19

75<b>Explanation</b>: What has been before <code><% this.hello key1="value01" %></code>, is now <code><hc:this.hello key1="value01" /></code>, which is nothing but a transformation of syntax. The difference now is, that additional parameters to the macro can be specified by embedding ha-tags into the hc-tag. (hc stands for helma-call, and ha for helma-argument, whereas i'm open for better names)

Version 7 by michi on 07. December 2005, 11:18

8* I consider pushing information to skins via the param-object resp response-object not desirable, since these parameters are hard to document for template designers.
9* keep it simple, and avoid magic, non-intuitive behavior
10[Still thinking; My current code snippets will follow]snippet:
33        obj.renderSkinAsString(createSkin(param[renderSkin(createSkin(param["body"]), skinParam);
73
74<b>Explanation</b>: What has been before <code><% this.hello key1="value01" %></code>, is now <code><hc:this.hello key1="value01" /></code>, which is nothing but a transformation of syntax. The difference now is, that additional parameters to the macro can be specified by embedding ha-tags into the hc-tag.
75
76Note: Lots of this.renderSkin(createSkin(.)) are needed in the above example, so an idea would be that Helma does that automatically for each 'ha'-macro argument, but then i wouldn't know how to push additional parameters to these strings/subskins.

Version 6 by michi on 07. December 2005, 11:11

22
40
44
50
51

Version 5 by michi on 07. December 2005, 11:11

10
11  # HopObject/macros.js
12  function count_macro(param) {
13    var cnt = this.count();
14    if (param[cnt.toString()]) {
15      res.write(param[cnt.toString()]);
16    } else if (param["n"]) {
17      res.write(param["n"]);
18    } else {
19      res.write(cnt);
20    }
21  }
22
23  function loop_macro(param) {
24    if (param["default"]) param["default"] = this.renderSkinAsString(createSkin(param["default"]));
25    if (param["prefix"]) param["prefix"] = this.renderSkinAsString(createSkin(param["prefix"]));
26    if (param["suffix"]) param["suffix"] = this.renderSkinAsString(createSkin(param["suffix"]));
27    for (var i=0; i<this.count(); i++) {
28      var obj = this.get(i);
29      var skinParam = {};
30      skinParam.cnt = i;
31      if (param.alternate) skinParam.alternateCnt = i % param.alternate;
32      if (param["body"]) {
33        obj.renderSkinAsString(createSkin(param["body"]), skinParam);
34      } else {
35        // render separate skin
36        obj.renderSkin(param["skin"] || "listitem", skinParam);
37      }
38    }
39  }
40
41  function msg_macro(param) {
42    renderSkin(createSkin(getText(param.id)));
43  }
44
45  # Global/functions.js
46  function getText(id) {
47    ..
48    return str;
49  }
50
51
52
53  <h1><hc:this.msg id="site.topics.header">All topics</hc:this.msg></h1>
54  <p><hc:this.topics.count>
55    <ha:0><hc:this.msg id="site.topics.noTopics">No topics to display.</hc:this.msg></ha:0>
56    <ha:1><hc:this.msg id="site.topics.oneTopic">This site has just one topic.</hc:this.msg></ha:1>
57    <ha:n><hc:this.msg id="site.topics.moreTopics">This site has <hc:this.count /> topics.</hc:this.msg></ha:n>
58  </hc:this.topics.count></p>
59  <hc:site.loop alternate="2">
60    <ha:prefix>
61    <table>
62      <tr>
63        <th><hc:this.msg id="site.topics.tableHead.topic">Topic</hc:this.msg></th>
64        <th><hc:this.msg id="site.topics.tableHead.numberOfStories">Number of Stories</hc:this.msg></th>
65      </tr>
66    </ha:prefix>
67    <ha:body>
68      <tr class="row<hc:param.alternateCnt />">
69        <td><hc:topic.name /></td>
70        <td><hc:topic.count /></td>
71      </tr>
72    </ha:body>
73    <ha:suffix>
74    </table>
75    </h:suffix>
76  </hc:site.loop>
77

Version 4 by michi on 07. December 2005, 09:43

7* <h:macro call="param.i" /> just seems to be an overkill for what has been <% <code><% param.i %> %></code> before

Version 3 by michi on 07. December 2005, 09:43

5* either use <% <code><% .. %> %></code> or <h:macro .. />, but dont allow both

Version 2 by michi on 06. December 2005, 22:18

4* allow walking through object-structure (not *really* really necessary, since this could be implemented by passing along a parameter to the macro, but a 'this.topics.count' is definitely prefered to 'this.count collection="topics"'

Version 1 by michi on 06. December 2005, 22:17

1NOTYETFINISHED
3* follow february-proposal, starting with andreas <a href="http://helma.org/pipermail/helma-dev/2005-February/001714.html">code snippet</a> from back then
4* allow walking through object-structure (not *really* necessary, since this could be implemented by passing along a parameter to the macro, but a 'this.topics.count' is definitely prefered to 'this.count collection="topics"'
5* either use <% .. %> or <h:macro .. />, but dont allow both
6* XHTML conformance of the templates is an absolut non-goal for me. i just dont see a reason for that. Additionally macros are inserted not just outside of tags, but also within e.g. a style-attribute of a tag. The <h:macro .. />-syntax there breaks xml-conformance anyways.
7* <h:macro call="param.i" /> just seems to be an overkill for what has been <% param.i %> before
8
9[Still thinking; code snippets will follow]