Helma Logo
main list history

Version 10 by michi on 06. December 2005, 21:32

1<b>Syntax example for helma.skins.2.0: (by by *matthias* - 2005/12/04)</b>2005/12/04

Version 9 by michi on 06. December 2005, 21:31

2click on "attach" and download the file (if anybody can help me linking that file without destroying the layout here i would be thankful)

Version 8 by michi on 06. December 2005, 21:18

20
24

Version 7 by michi on 06. December 2005, 21:18

27
33
39
40
42
45
57
64
65
67   myExtension/code/topicList.macros.js   
68
71
74
78
97

Version 6 by michi on 06. December 2005, 21:17

14<pre>
15<?xml version="1.0" encoding="UTF-8"?>
16<!DOCTYPE html
17 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
18 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
16<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:h="http://helma.org/schema/skins2.0">
17<head>
18<title>Helma 2.0 Templates</title>
18<script type <?xml version="text/javascript1.0" runatencoding="serverUTF-8"><!-- ?>
19/* <!DOCTYPE html
20 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
21 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20Macro.renderOpenTag <html xmlns="http://www.w3.org/1999/xhtml" function(param,xml:lang="en" skins) xmlns:h="http://helma.org/schema/skins2.0"
21 if (param["h:nodeName"]) <head>
22 Html<title>Helma 2.openTag(param["h:nodeName"], param);0 Templates</title>
23
24 <script type="text/javascript" runat="server"><!--
25 /*
26
27 Macro.renderOpenTag = function(param, skins) {
28 if (param["h:nodeName"]) {
29 Html.openTag(param["h:nodeName"], param);
30 }
22}
24 Macro.renderCloseTag = function(param, skins)
25 if (param["h:nodeName"])
26 Html.closeTag(param["h:nodeName"]);
27 }
26}
29 Site.prototype.topicList_macro = function(param, skins, macro)
30 if (this.topics.count() == 0) return; // use default
31 // instead of this, we could introduce 'h:renderTag="true|false"' as a standard attribute
32 Macro.renderOpenTag(param, skins);
33 for (var i = 0; i < this.topics.count(); i++)
34 var topic = this.topics.get(i);
35 res.handlers.topic = topic;
36 topic.renderSkin(skins["listItem"]);
37 delete(res.handlers.topic);
38 }
39 if (param["h:nodeName"]) {
40 Html.openTag(param["h:nodeName"], param);
41 }
42 Macro.renderCloseTag(param, skins);
35 if (param["h:nodeName"])
36 HtmlTopicCommentMgr.openTag(param["h:nodeName"]prototype.count_macro = function(param, param);skins)
37 var commentCnt = this.count();
38 if (commentCnt == 0) this.renderSkin(skins["no"]);
39 else if (commentCnt == 1) this.renderSkin(skins["one"]);
40 else this.renderSkin(skins["more"], {count: commentCnt});
37 Macro.renderCloseTag(param, skins);
38}
39TopicCommentMgr.prototype.count_macro = function(param, skins) {
40 var commentCnt = this.count();
41 if (commentCnt == 0) this.renderSkin(skins["no"]);
42 else if (commentCnt == 1) this.renderSkin(skins["one"]);
43 else this.renderSkin(skins["more"], {count: commentCnt});
44}
41 alternative code structure:
42 # lowerCase indicates, that "topicList" is not a prototype -> code convention
43 myExtension/code/topicList.macros.js   
43alternative code structure: # if the first part of a skin file name is CamelCase handle it as a prototype
44# lowerCase indicates, that " myExtension/code/Site.topicList" is not a prototype -> code convention.example.skin
45myExtension/code/topicList myExtension/code/Topic.macroslistItem.js    skin
45# if the first part of a skin file name is CamelCase handle it as a prototype */
46myExtension/code/Site.topicList.example.skin // --></script>
47myExtension/code/Topic.listItem.skin
47*/ </head>
48// --></script>
49</head> <body>
51<body> <!--table h:macro="site.loop" h:collection="topics" h:as="topic" border="1"-->
52 <table h:macro="site.topicList" border="1" h:renderTag="true">
53 <tr h:name="prefix">
54 <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
55 <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
56 </tr>
57 <tr h:name="listItem">
58 <td><h:topic.name>Topic Name</h:topic.name></td>
59 <td><h:topic.comments.count>
60 <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
61 <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
62 <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
63 </h:topic.comments.count></td>
64 </tr>
65 <!--tr h:name="default">
66 <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
67 </tr-->
68 </table>
53<!--table h:macro="site.loop" h:collection="topics" h:as="topic" border="1"--> </body>
54<table h:macro="site.topicList" border="1" h:renderTag="true" </html>
55 <tr h:name="prefix">
56 <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
57 <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
58 </tr>
59 <tr h:name="listItem">
60 <td><h:topic.name>Topic Name</h:topic.name></td>
61 <td><h:topic.comments.count>
62 <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
63 <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
64 <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
65 </h:topic.comments.count></td>
66 </tr>
67 <!--tr h:name="default">
68 <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
69 </tr-->
70</table>

Version 5 by michi on 06. December 2005, 21:17

15 <?xml version="1.0" encoding="UTF-8"?>
16 <!DOCTYPE html
17 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
18 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
17 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:h="http://helma.org/schema/skins2.0"
18 <head>
19 <title>Helma 2.0 Templates</title>
19 <script type="text/javascript" runat="server"><!--
20 /*
21 Macro.renderOpenTag = function(param, skins)
22 if (param["h:nodeName"])
23 Html.openTag(param["h:nodeName"], param);
24 }
23}
25 Macro.renderCloseTag = function(param, skins)
26 if (param["h:nodeName"])
27 Html.closeTag(param["h:nodeName"]);
28 }
27}
30 Site.prototype.topicList_macro = function(param, skins, macro)
31 if (this.topics.count() == 0) return; // use default
32 // instead of this, we could introduce 'h:renderTag="true|false"' as a standard attribute
33 Macro.renderOpenTag(param, skins);
34 for (var i = 0; i < this.topics.count(); i++)
35 var topic = this.topics.get(i);
36 res.handlers.topic = topic;
37 topic.renderSkin(skins["listItem"]);
38 delete(res.handlers.topic);
39 }
40 if (param["h:nodeName"]) {
41 Html.openTag(param["h:nodeName"], param);
42 }
43 Macro.renderCloseTag(param, skins);
36 if (param["h:nodeName"])
37 TopicCommentMgr.prototype.count_macro = function(param Html.openTag(param["h:nodeName"], skins) param);
38 var commentCnt = this.count();
39 if (commentCnt == 0) this.renderSkin(skins["no"]);
40 else if (commentCnt == 1) this.renderSkin(skins["one"]);
41 else this.renderSkin(skins["more"], {count: commentCnt});
38 Macro.renderCloseTag(param, skins);
39}
40TopicCommentMgr.prototype.count_macro = function(param, skins) {
41 var commentCnt = this.count();
42 if (commentCnt == 0) this.renderSkin(skins["no"]);
43 else if (commentCnt == 1) this.renderSkin(skins["one"]);
44 else this.renderSkin(skins["more"], {count: commentCnt});
45}
42 alternative code structure:
43 # lowerCase indicates, that "topicList" is not a prototype -> code convention
44 myExtension/code/topicList.macros.js   
44 # if the first part of a skin file name is CamelCase handle it as a prototypealternative code structure:
45# lowerCase indicates, that myExtension/code/Site."topicList.example.skin" is not a prototype -> code convention
46 myExtension/code/TopicmyExtension/code/topicList.listItemmacros.skinjs   
46 */# if the first part of a skin file name is CamelCase handle it as a prototype
47 // --></script>myExtension/code/Site.topicList.example.skin
48myExtension/code/Topic.listItem.skin
48 </head>*/
49// --></script>
50 <body></head>
52 <!--table h:macro="site.loop" h:collection="topics" h:as="topic" border="1"--><body>
53 <table h:macro="site.topicList" border="1" h:renderTag="true">
54 <tr h:name="prefix">
55 <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
56 <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
57 </tr>
58 <tr h:name="listItem">
59 <td><h:topic.name>Topic Name</h:topic.name></td>
60 <td><h:topic.comments.count>
61 <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
62 <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
63 <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
64 </h:topic.comments.count></td>
65 </tr>
66 <!--tr h:name="default">
67 <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
68 </tr-->
69 </table>
54<!--table h:macro= </body>"site.loop" h:collection="topics" h:as="topic" border="1"-->
55<table h:macro= </html>"site.topicList" border="1" h:renderTag="true"
56 <tr h:name="prefix">
57 <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
58 <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
59 </tr>
60 <tr h:name="listItem">
61 <td><h:topic.name>Topic Name</h:topic.name></td>
62 <td><h:topic.comments.count>
63 <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
64 <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
65 <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
66 </h:topic.comments.count></td>
67 </tr>
68 <!--tr h:name="default">
69 <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
70 </tr-->
71</table>
72
73</body>
74</html>

Version 4 by michi on 06. December 2005, 21:16

14<pre>
102</pre>

Version 3 by michi on 06. December 2005, 21:15

15<code> <?xml version="1.0" encoding="UTF-8"?>
16<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html
17<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
18    PUBLIC "-//W3C//DTD XHTML 1http://www.0 Strict//ENw3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
19    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:h="http://helma.org/schema/skins2.0"
18 <head>
19 <title>Helma 2.0 Templates</title>
19 <script type="text/javascript" runat="server"><!--
20 /*
21 Macro.renderOpenTag = function(param, skins)
22   if (param["h:nodeName"])
23     Html.openTag(param["h:nodeName"], param);
24  
25
23 Macro.renderCloseTag = function(param, skins)
24   if (param["h:nodeName"])
25     Html.closeTag(param["h:nodeName"]);
26  
27
26 Site.prototype.topicList_macro = function(param, skins, macro)
27   if (this.topics.count() == 0) return; // use default
28   // instead of this, we could introduce 'h:renderTag="true|false"' as a standard attribute
29   Macro.renderOpenTag(param, skins);
30   for (var i = 0; i < this.topics.count(); i++)
31     var topic = this.topics.get(i);
32     res.handlers.topic = topic;
33     topic.renderSkin(skins["listItem"]);
34     delete(res.handlers.topic);
35  
36   if (param["h:nodeName"])
37     Html.openTag(param["h:nodeName"], param);
38  
39   Macro.renderCloseTag(param, skins);
40
32 TopicCommentMgr.prototype.count_macro = function(param, skins)
33   var commentCnt = this.count();
34   if (commentCnt == 0) this.renderSkin(skins["no"]);
35   else if (commentCnt == 1) this.renderSkin(skins["one"]);
36   else this.renderSkin(skins["more"], {count: commentCnt});
37
35 alternative code structure:
36 # lowerCase indicates, that "topicList" is not a prototype -> code convention
37 myExtension/code/topicList.macros.js   
37 # if the first part of a skin file name is CamelCase handle it as a prototype
38 myExtension/code/Site.topicList.example.skin
39 myExtension/code/Topic.listItem.skin
39 */
40 // --></script>
41 </head>
43 <body>
45 <!--table h:macro="site.loop" h:collection="topics" h:as="topic" border="1"-->
46 <table h:macro="site.topicList" border="1" h:renderTag="true"
47   <tr h:name="prefix"
48     <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
49     <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
50   </tr>
51   <tr h:name="listItem"
52     <td><h:topic.name>Topic Name</h:topic.name></td>
53     <td><h:topic.comments.count>
54    <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
55    <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
56    <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
57 </h:topic.comments.count></td>
58   </tr>
59   <!--tr h:name="default"
60     <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
61   </tr-->
62 </table>
47 </body>
48 </html>
49</code>

Version 2 by michi on 06. December 2005, 21:14

15<code>
16<?xml version="1.0" encoding="UTF-8"?>
17<!DOCTYPE html
18    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
19    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20
21<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:h="http://helma.org/schema/skins2.0">
22<head>
23<title>Helma 2.0 Templates</title>
24
25<script type="text/javascript" runat="server"><!--
26/*
27
28Macro.renderOpenTag = function(param, skins) {
29  if (param["h:nodeName"]) {
30    Html.openTag(param["h:nodeName"], param);
31  }
32}
33
34Macro.renderCloseTag = function(param, skins) {
35  if (param["h:nodeName"]) {
36    Html.closeTag(param["h:nodeName"]);
37  }
38}
39
40
41Site.prototype.topicList_macro = function(param, skins, macro) {
42  if (this.topics.count() == 0) return; // use default
43
44  // instead of this, we could introduce 'h:renderTag="true|false"' as a standard attribute
45  Macro.renderOpenTag(param, skins);
46
47  for (var i = 0; i < this.topics.count(); i++) {
48    var topic = this.topics.get(i);
49    res.handlers.topic = topic;
50    topic.renderSkin(skins["listItem"]);
51    delete(res.handlers.topic);
52  }
53  if (param["h:nodeName"]) {
54    Html.openTag(param["h:nodeName"], param);
55  }
56  Macro.renderCloseTag(param, skins);
57}
58
59TopicCommentMgr.prototype.count_macro = function(param, skins) {
60  var commentCnt = this.count();
61  if (commentCnt == 0) this.renderSkin(skins["no"]);
62  else if (commentCnt == 1) this.renderSkin(skins["one"]);
63  else this.renderSkin(skins["more"], {count: commentCnt});
64}
65
66
67alternative code structure:
68# lowerCase indicates, that "topicList" is not a prototype -> code convention
69myExtension/code/topicList.macros.js   
70
71# if the first part of a skin file name is CamelCase handle it as a prototype
72myExtension/code/Site.topicList.example.skin
73myExtension/code/Topic.listItem.skin
74
75*/
76// --></script>
77
78</head>
79
80<body>
81
82<!--table h:macro="site.loop" h:collection="topics" h:as="topic" border="1"-->
83<table h:macro="site.topicList" border="1" h:renderTag="true">
84  <tr h:name="prefix">
85    <th><h:msg name="site.topics.list.heading.topicName">Topic Name</h:msg></th>
86    <th><h:msg name="site.topics.list.heading.commentCount">Comment Count</h:msg></th>
87  </tr>
88  <tr h:name="listItem">
89    <td><h:topic.name>Topic Name</h:topic.name></td>
90    <td><h:topic.comments.count>
91   <h:skin name="no"><!--h:msg name="comments.count.no">No comments yet</h:msg--></h:skin>
92   <h:skin name="one"><h:msg name="comments.count.no"><!-- 1 comment --></h:msg></h:skin>
93   <h:skin name="more"><h:msg name="comments.count.no"><h:param.count >34</h:param.count> comments</h:msg></h:skin>
94 </h:topic.comments.count></td>
95  </tr>
96  <!--tr h:name="default">
97    <td colspan="2" align="center"><h:msg name="site.topics.list.isEmpty">This list is empty</h:msg></td>
98  </tr-->
99</table>
100
101</body>
102</html>
103</code>

Version 1 by michi on 06. December 2005, 21:14

1<b>Syntax example for helma.skins.2.0: (by *matthias* - 2005/12/04)</b>
2click on "attach" and download the file (if anybody can help me linking that file without destroying the layout here i would be thankful)
3
4it:
5* is valid xml
6* renders in a browser (without showing ugly server code) -> you might need to rename the extension to *.html
7* seperates logic from template
8* avoids the need of having many, many files...
9* is based on the proposal from hannes (see link above)
10* introduces &lt;h:Prototype.macroName /&gt; as an alternative to h:macro="Prototype.macroName"
11
12Note:
13the &lt;script runat="server"&gt; is just there to have the code in the same file. the idea would be to allow it just for file based skins and evaluate it just the same way as code in .js files.