kwartz 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog +103 -0
  3. data/README.txt +37 -0
  4. data/bin/kwartz +12 -0
  5. data/doc-api/classes/Kwartz.html +218 -0
  6. data/doc-api/classes/Kwartz/Assertion.html +140 -0
  7. data/doc-api/classes/Kwartz/AssertionError.html +148 -0
  8. data/doc-api/classes/Kwartz/AttrInfo.html +320 -0
  9. data/doc-api/classes/Kwartz/BaseError.html +206 -0
  10. data/doc-api/classes/Kwartz/BaseTranslator.html +331 -0
  11. data/doc-api/classes/Kwartz/CharacterType.html +212 -0
  12. data/doc-api/classes/Kwartz/CommandOptionError.html +154 -0
  13. data/doc-api/classes/Kwartz/CommandOptions.html +374 -0
  14. data/doc-api/classes/Kwartz/Config.html +150 -0
  15. data/doc-api/classes/Kwartz/ConvertError.html +191 -0
  16. data/doc-api/classes/Kwartz/Converter.html +252 -0
  17. data/doc-api/classes/Kwartz/CssStyleParser.html +483 -0
  18. data/doc-api/classes/Kwartz/DocumentRuleset.html +369 -0
  19. data/doc-api/classes/Kwartz/ElementExpander.html +325 -0
  20. data/doc-api/classes/Kwartz/ElementInfo.html +312 -0
  21. data/doc-api/classes/Kwartz/ElementRuleset.html +582 -0
  22. data/doc-api/classes/Kwartz/EperlHandler.html +338 -0
  23. data/doc-api/classes/Kwartz/EperlTranslator.html +167 -0
  24. data/doc-api/classes/Kwartz/ErubisHandler.html +113 -0
  25. data/doc-api/classes/Kwartz/ErubisTranslator.html +168 -0
  26. data/doc-api/classes/Kwartz/ErubyHandler.html +337 -0
  27. data/doc-api/classes/Kwartz/ErubyTranslator.html +167 -0
  28. data/doc-api/classes/Kwartz/ExpandStatement.html +227 -0
  29. data/doc-api/classes/Kwartz/Expression.html +119 -0
  30. data/doc-api/classes/Kwartz/Handler.html +558 -0
  31. data/doc-api/classes/Kwartz/JstlHandler.html +657 -0
  32. data/doc-api/classes/Kwartz/JstlTranslator.html +226 -0
  33. data/doc-api/classes/Kwartz/KwartzError.html +146 -0
  34. data/doc-api/classes/Kwartz/Main.html +384 -0
  35. data/doc-api/classes/Kwartz/NativeExpression.html +236 -0
  36. data/doc-api/classes/Kwartz/NativeStatement.html +254 -0
  37. data/doc-api/classes/Kwartz/Node.html +156 -0
  38. data/doc-api/classes/Kwartz/ParseError.html +148 -0
  39. data/doc-api/classes/Kwartz/PhpHandler.html +333 -0
  40. data/doc-api/classes/Kwartz/PhpTranslator.html +194 -0
  41. data/doc-api/classes/Kwartz/PresentationLogicParser.html +830 -0
  42. data/doc-api/classes/Kwartz/PrintStatement.html +221 -0
  43. data/doc-api/classes/Kwartz/RailsHandler.html +587 -0
  44. data/doc-api/classes/Kwartz/RailsTranslator.html +167 -0
  45. data/doc-api/classes/Kwartz/RubyStyleParser.html +558 -0
  46. data/doc-api/classes/Kwartz/Ruleset.html +117 -0
  47. data/doc-api/classes/Kwartz/Statement.html +119 -0
  48. data/doc-api/classes/Kwartz/StrutsTranslator.html +190 -0
  49. data/doc-api/classes/Kwartz/TagInfo.html +314 -0
  50. data/doc-api/classes/Kwartz/TextConverter.html +270 -0
  51. data/doc-api/classes/Kwartz/Translator.html +318 -0
  52. data/doc-api/classes/Test.html +107 -0
  53. data/doc-api/classes/Test/Unit.html +101 -0
  54. data/doc-api/created.rid +1 -0
  55. data/doc-api/files/__/README_txt.html +150 -0
  56. data/doc-api/files/kwartz/assert_rb.html +114 -0
  57. data/doc-api/files/kwartz/binding/eperl_rb.html +116 -0
  58. data/doc-api/files/kwartz/binding/erubis_rb.html +116 -0
  59. data/doc-api/files/kwartz/binding/eruby_rb.html +115 -0
  60. data/doc-api/files/kwartz/binding/jstl_rb.html +116 -0
  61. data/doc-api/files/kwartz/binding/php_rb.html +116 -0
  62. data/doc-api/files/kwartz/binding/rails_rb.html +115 -0
  63. data/doc-api/files/kwartz/binding/struts_rb.html +117 -0
  64. data/doc-api/files/kwartz/config_rb.html +107 -0
  65. data/doc-api/files/kwartz/converter_rb.html +119 -0
  66. data/doc-api/files/kwartz/error_rb.html +107 -0
  67. data/doc-api/files/kwartz/main_rb.html +124 -0
  68. data/doc-api/files/kwartz/node_rb.html +114 -0
  69. data/doc-api/files/kwartz/parser_rb.html +117 -0
  70. data/doc-api/files/kwartz/translator_rb.html +115 -0
  71. data/doc-api/files/kwartz/util/assert-text-equal_rb.html +115 -0
  72. data/doc-api/files/kwartz/util/testcase-helper_rb.html +115 -0
  73. data/doc-api/files/kwartz_rb.html +120 -0
  74. data/doc-api/fr_class_index.html +75 -0
  75. data/doc-api/fr_file_index.html +45 -0
  76. data/doc-api/fr_method_index.html +216 -0
  77. data/doc-api/index.html +24 -0
  78. data/doc-api/rdoc-style.css +208 -0
  79. data/doc/docstyle.css +188 -0
  80. data/doc/p-pattern.html +1207 -0
  81. data/doc/reference.html +3396 -0
  82. data/doc/users-guide.html +1670 -0
  83. data/examples/breadcrumbs1/Makefile +15 -0
  84. data/examples/breadcrumbs1/breadcrumbs.eruby.plogic +27 -0
  85. data/examples/breadcrumbs1/breadcrumbs.html +12 -0
  86. data/examples/breadcrumbs1/breadcrumbs.jstl.plogic +28 -0
  87. data/examples/breadcrumbs1/breadcrumbs.php.plogic +26 -0
  88. data/examples/breadcrumbs1/main.php +12 -0
  89. data/examples/breadcrumbs1/main.rb +12 -0
  90. data/examples/breadcrumbs2/Makefile +15 -0
  91. data/examples/breadcrumbs2/breadcrumbs.eruby.plogic +22 -0
  92. data/examples/breadcrumbs2/breadcrumbs.html +14 -0
  93. data/examples/breadcrumbs2/breadcrumbs.jstl.plogic +24 -0
  94. data/examples/breadcrumbs2/breadcrumbs.php.plogic +23 -0
  95. data/examples/breadcrumbs2/main.php +12 -0
  96. data/examples/breadcrumbs2/main.rb +12 -0
  97. data/examples/pagelayout/Makefile +47 -0
  98. data/examples/pagelayout/content.eruby.plogic +44 -0
  99. data/examples/pagelayout/content.jstl.plogic +36 -0
  100. data/examples/pagelayout/content.php.plogic +37 -0
  101. data/examples/pagelayout/content1.html +36 -0
  102. data/examples/pagelayout/content2.html +29 -0
  103. data/examples/pagelayout/design.css +40 -0
  104. data/examples/pagelayout/layout.html +50 -0
  105. data/examples/pagelayout/main.php +55 -0
  106. data/examples/pagelayout/main.rb +77 -0
  107. data/examples/pagelayout/menu.eruby.plogic +14 -0
  108. data/examples/pagelayout/menu.html +13 -0
  109. data/examples/pagelayout/menu.jstl.plogic +14 -0
  110. data/examples/pagelayout/menu.php.plogic +14 -0
  111. data/examples/rails1/Makefile +36 -0
  112. data/examples/rails1/README +19 -0
  113. data/examples/rails1/application_helper.rb +31 -0
  114. data/examples/rails1/edit.html +28 -0
  115. data/examples/rails1/edit.plogic +10 -0
  116. data/examples/rails1/form.html +52 -0
  117. data/examples/rails1/form.plogic +33 -0
  118. data/examples/rails1/layout.plogic +15 -0
  119. data/examples/rails1/link_to.plogic +19 -0
  120. data/examples/rails1/list.html +48 -0
  121. data/examples/rails1/list.plogic +28 -0
  122. data/examples/rails1/new.html +27 -0
  123. data/examples/rails1/new.plogic +10 -0
  124. data/examples/rails1/reader.plogic +29 -0
  125. data/examples/rails1/show.html +40 -0
  126. data/examples/rails1/show.plogic +4 -0
  127. data/examples/rails1/writer.plogic +8 -0
  128. data/examples/table1/Makefile +15 -0
  129. data/examples/table1/main.php +11 -0
  130. data/examples/table1/main.rb +11 -0
  131. data/examples/table1/table1.eruby.plogic +21 -0
  132. data/examples/table1/table1.html +16 -0
  133. data/examples/table1/table1.jstl.plogic +21 -0
  134. data/examples/table1/table1.php.plogic +22 -0
  135. data/kwartz.gemspec +55 -0
  136. data/lib/kwartz.rb +13 -0
  137. data/lib/kwartz/assert.rb +31 -0
  138. data/lib/kwartz/binding/eperl.rb +166 -0
  139. data/lib/kwartz/binding/erubis.rb +61 -0
  140. data/lib/kwartz/binding/eruby.rb +164 -0
  141. data/lib/kwartz/binding/jstl.rb +334 -0
  142. data/lib/kwartz/binding/php.rb +167 -0
  143. data/lib/kwartz/binding/rails.rb +295 -0
  144. data/lib/kwartz/binding/struts.rb +109 -0
  145. data/lib/kwartz/config.rb +28 -0
  146. data/lib/kwartz/converter.rb +920 -0
  147. data/lib/kwartz/error.rb +41 -0
  148. data/lib/kwartz/main.rb +464 -0
  149. data/lib/kwartz/node.rb +454 -0
  150. data/lib/kwartz/parser.rb +903 -0
  151. data/lib/kwartz/translator.rb +153 -0
  152. data/lib/kwartz/util/assert-text-equal.rb +44 -0
  153. data/lib/kwartz/util/testcase-helper.rb +112 -0
  154. data/setup.rb +1331 -0
  155. data/test/test-compile.rb +36 -0
  156. data/test/test-compile.yaml +178 -0
  157. data/test/test-converter.rb +34 -0
  158. data/test/test-converter.yaml +127 -0
  159. data/test/test-directives.rb +32 -0
  160. data/test/test-directives.yaml +1411 -0
  161. data/test/test-main.rb +464 -0
  162. data/test/test-parser.rb +54 -0
  163. data/test/test-parser.yaml +394 -0
  164. data/test/test-rails.rb +28 -0
  165. data/test/test-rails.yaml +301 -0
  166. data/test/test-ruleset.rb +36 -0
  167. data/test/test-ruleset.yaml +804 -0
  168. data/test/test.rb +44 -0
  169. metadata +236 -0
@@ -0,0 +1,36 @@
1
+ ###
2
+ ### $Rev: 117 $
3
+ ### $Release: 3.0.0 $
4
+ ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
+ ###
6
+
7
+
8
+ require "#{File.dirname(__FILE__)}/test.rb"
9
+
10
+
11
+ class CompileTest < Test::Unit::TestCase
12
+
13
+
14
+ ## define test methods
15
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
16
+ load_yaml_testdata_with_each_lang(filename, :langs=>%w[eruby php jstl eperl])
17
+
18
+
19
+ def _test
20
+ regexp = /(\{\{\*|\*\}\})/
21
+ @pdata.gsub!(regexp, '') if @pdata
22
+ @plogic.gsub!(regexp, '') if @plogic
23
+ @expected.gsub!(regexp, '') if @expected
24
+ #
25
+ parser = Kwartz::PresentationLogicParser.get_class('css').new
26
+ ruleset_list = parser.parse(@plogic)
27
+ handler = Kwartz::Handler.get_class(@lang).new(ruleset_list)
28
+ converter = Kwartz::TextConverter.new(handler)
29
+ stmt_list = converter.convert(@pdata)
30
+ translator = Kwartz::Translator.get_class(@lang).new
31
+ actual = translator.translate(stmt_list)
32
+ assert_text_equal(@expected, actual)
33
+ end
34
+
35
+
36
+ end
@@ -0,0 +1,178 @@
1
+ - name: compile1
2
+ desc: bordered table
3
+
4
+ pdata: |
5
+ <?xml version="1.0" encoding="UTF-8"?>
6
+ <html>
7
+ <body>
8
+ <table>
9
+ <tr bgcolor="#FFCCCC" {{*id="mark:list"*}}>
10
+ <td {{*id="mark:name"*}}>foo</td>
11
+ <td {{*id="mark:mail"*}}>foo@mail.com</td>
12
+ </tr>
13
+ <tr {{*id="dummy:d1"*}} bgcolor="#CCCCFF">
14
+ <td>bar</td>
15
+ <td>bar@mail.org</td>
16
+ </tr>
17
+ </table>
18
+ </body>
19
+ </html>
20
+
21
+
22
+ plogic*:
23
+
24
+ eruby: |
25
+ #list {
26
+ attrs: 'bgcolor' color,
27
+ 'title' user.name;
28
+ logic: {
29
+ @list.each_with_index { |user, i|
30
+ color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'
31
+ _stag
32
+ _cont
33
+ _etag
34
+ }
35
+ }
36
+ }
37
+ #name {
38
+ Value: user.name;
39
+ }
40
+ #mail {
41
+ cont: user[:mail];
42
+ }
43
+
44
+ php: |
45
+ #list {
46
+ attrs: 'bgcolor' $color,
47
+ 'title' $user->name;
48
+ logic: {
49
+ $i = 0;
50
+ foreach ($list as $user) {
51
+ $i++;
52
+ $color = $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF';
53
+ _stag();
54
+ _cont();
55
+ _etag();
56
+ }
57
+ }
58
+ }
59
+ #name {
60
+ Value: $user->name;
61
+ }
62
+ #mail {
63
+ cont: $user['mail'];
64
+ }
65
+
66
+ jstl: |
67
+ #list {
68
+ attrs: 'bgcolor' color,
69
+ 'title' user.name;
70
+ logic: {
71
+ <c:forEach var="user" items="${list}" varStatus="loop">
72
+ <c:set var="color" value="${loop.count % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}"/>
73
+ _stag();
74
+ _cont();
75
+ _etag();
76
+ </c:forEach>
77
+ }
78
+ }
79
+ #name {
80
+ Value: user.name;
81
+ }
82
+ #mail {
83
+ cont: user.mail;
84
+ }
85
+
86
+ eperl: |
87
+ #list {
88
+ attrs: 'bgcolor' $color,
89
+ 'title' $user->name();
90
+ logic: {
91
+ my $i = 0;
92
+ foreach my $user (@list) {
93
+ $i++;
94
+ my $color = $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF';
95
+ _stag();
96
+ _cont();
97
+ _etag();
98
+ }
99
+ }
100
+ }
101
+ #name {
102
+ Value: $user->name();
103
+ }
104
+ #mail {
105
+ cont: $user{'mail'};
106
+ }
107
+
108
+ expected*:
109
+
110
+ eruby: |
111
+ <?xml version="1.0" encoding="UTF-8"?>
112
+ <html>
113
+ <body>
114
+ <table>
115
+ {{*<% @list.each_with_index { |user, i| %>*}}
116
+ {{*<% color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>*}}
117
+ <tr bgcolor="{{*<%= color %>*}}" title="{{*<%= user.name %>*}}">
118
+ <td>{{*<%=h user.name %>*}}</td>
119
+ <td>{{*<%= user[:mail] %>*}}</td>
120
+ </tr>
121
+ <% } %>
122
+ </table>
123
+ </body>
124
+ </html>
125
+
126
+ php: |
127
+ <{{*<?php ?>*}}?xml version="1.0" encoding="UTF-8"?>
128
+ <html>
129
+ <body>
130
+ <table>
131
+ {{*<?php $i = 0; ?>*}}
132
+ {{*<?php foreach ($list as $user) { ?>*}}
133
+ {{*<?php $i++; ?>*}}
134
+ {{*<?php $color = $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; ?>*}}
135
+ <tr bgcolor="{{*<?php echo $color; ?>*}}" title="{{*<?php echo $user->name; ?>*}}">
136
+ <td>{{*<?php echo htmlspecialchars($user->name); ?>*}}</td>
137
+ <td>{{*<?php echo $user['mail']; ?>*}}</td>
138
+ </tr>
139
+ {{*<?php } ?>*}}
140
+ </table>
141
+ </body>
142
+ </html>
143
+
144
+ jstl: |
145
+ {{*<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>*}}
146
+ {{*<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>*}}
147
+ <?xml version="1.0" encoding="UTF-8"?>
148
+ <html>
149
+ <body>
150
+ <table>
151
+ {{*<c:forEach var="user" items="${list}" varStatus="loop">*}}
152
+ {{*<c:set var="color" value="${loop.count % 2 == 0 ? '#FFCCCC' : '#CCCCFF'}"/>*}}
153
+ <tr bgcolor="{{*${color}*}}" title="{{*${user.name}*}}">
154
+ <td>{{*${user.name}*}}</td>
155
+ <td>{{*${user.mail}*}}</td>
156
+ </tr>
157
+ {{*</c:forEach>*}}
158
+ </table>
159
+ </body>
160
+ </html>
161
+
162
+ eperl: |
163
+ <?xml version="1.0" encoding="UTF-8"?>
164
+ <html>
165
+ <body>
166
+ <table>
167
+ {{*<? my $i = 0; !>*}}
168
+ {{*<? foreach my $user (@list) { !>*}}
169
+ {{*<? $i++; !>*}}
170
+ {{*<? my $color = $i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'; !>*}}
171
+ <tr bgcolor="{{*<?= $color !>*}}" title="{{*<?= $user->name() !>*}}">
172
+ <td>{{*<?= encode_entities($user->name()) !>*}}</td>
173
+ <td>{{*<?= $user{'mail'} !>*}}</td>
174
+ </tr>
175
+ {{*<? } !>*}}
176
+ </table>
177
+ </body>
178
+ </html>
@@ -0,0 +1,34 @@
1
+ ###
2
+ ### $Rev: 114 $
3
+ ### $Release: 3.0.0 $
4
+ ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
+ ###
6
+
7
+ require "#{File.dirname(__FILE__)}/test.rb"
8
+
9
+
10
+ class ConverterTest < Test::Unit::TestCase
11
+
12
+
13
+ ## define test methods
14
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
15
+ load_yaml_testdata(filename)
16
+
17
+
18
+ def _test
19
+ parser = Kwartz::PresentationLogicParser.get_class('css').new
20
+ ruleset_list = parser.parse(@plogic)
21
+ #handler = Kwartz::Handler.new(ruleset_list)
22
+ handler = Kwartz::ErubyHandler.new(ruleset_list, :delspan=>true)
23
+ converter = Kwartz::TextConverter.new(handler, :delspan=>true)
24
+ stmt_list = converter.convert(@pdata)
25
+ sb = ''
26
+ stmt_list.each do |stmt|
27
+ sb << (s = stmt._inspect)
28
+ sb << "\n" unless s[-1] == ?\n
29
+ end
30
+ assert_text_equal(@expected, sb)
31
+ end
32
+
33
+
34
+ end
@@ -0,0 +1,127 @@
1
+ ---
2
+ - name: span1
3
+ pdata: |
4
+ <p>
5
+ <span id="foo">FOO</span>
6
+ <span id="mark:bar">BAR</span>
7
+ <span title="id: baz">BAZ</span>
8
+ <span id="mark:poo" class="foo">POO</span>
9
+ </p>
10
+ <p>
11
+ <span title="attr: 'class' classname">ATTR</span>
12
+ <span title="append: ' checked'">APPEND</span>
13
+ <span title="append: ' checked'" class="foo">APPEND</span>
14
+ </p>
15
+ <p>
16
+ <span title="value: expr">EXPR</span>
17
+ <span title="value: expr" class="foo">EXPR</span>
18
+ </p>
19
+ <p>
20
+ <span title="if x > 0">positive</span>
21
+ <span title="elsif x < 0">negative</span>
22
+ <span title="else">zero</span>
23
+ </p>
24
+
25
+ plogic: |
26
+
27
+ expected: |
28
+ [ "<p>\n"]
29
+ [ " <span id=\"foo\">"]
30
+ [ "FOO"]
31
+ [ "</span>\n"]
32
+ [ ]
33
+ [ "BAR"]
34
+ [ ]
35
+ [ ]
36
+ [ "BAZ"]
37
+ [ ]
38
+ [ " <span class=\"foo\">"]
39
+ [ "POO"]
40
+ [ "</span>\n"]
41
+ [ "</p>\n"]
42
+ [ "<p>\n"]
43
+ [ " <span class=\"", <%=classname%>, "\">"]
44
+ [ "ATTR"]
45
+ [ "</span>\n"]
46
+ [ " <span", <%=' checked'%>, ">"]
47
+ [ "APPEND"]
48
+ [ "</span>\n"]
49
+ [ " <span class=\"foo\"", <%=' checked'%>, ">"]
50
+ [ "APPEND"]
51
+ [ "</span>\n"]
52
+ [ "</p>\n"]
53
+ [ "<p>\n"]
54
+ [ <%=expr%>]
55
+ [ " <span class=\"foo\">", <%=expr%>, "</span>\n"]
56
+ [ "</p>\n"]
57
+ [ "<p>\n"]
58
+ "if x > 0 then"
59
+ [ ]
60
+ [ "positive"]
61
+ [ ]
62
+ "elsif x < 0 then"
63
+ [ ]
64
+ [ "negative"]
65
+ [ ]
66
+ "else"
67
+ [ ]
68
+ [ "zero"]
69
+ [ ]
70
+ "end"
71
+ [ "</p>\n"]
72
+
73
+ output: |
74
+
75
+ ###
76
+ #- name: span2
77
+ # pdata: |
78
+ # <p>
79
+ # <span id="mark:section1">title</span>
80
+ # <span id="mark:section2">title</span>
81
+ # <span id="mark:section3">title</span>
82
+ # </p>
83
+ #
84
+ # plogic: |
85
+ # #section1 {
86
+ # value: title1;
87
+ # }
88
+ # #section2 {
89
+ # value: title2;
90
+ # attrs: "class" name;
91
+ # }
92
+ # #section3 {
93
+ # value: title3;
94
+ # append: ' checked="checked"';
95
+ # }
96
+ #
97
+ # expected: |
98
+ # [ "<p>\n"]
99
+ # [ ]
100
+ # [ <%=title1%>]
101
+ # [ ]
102
+ # [ " <span class=\"", <%=name%>, "\">"]
103
+ # [ <%=title2%>]
104
+ # [ "</span>\n"]
105
+ # [ " <span", <%=' checked="checked"'%>, ">"]
106
+ # [ <%=title3%>]
107
+ # [ "</span>\n"]
108
+ # [ "</p>\n"]
109
+ #
110
+ #
111
+ # output: |
112
+ #
113
+
114
+
115
+ ##
116
+ - name: unmatched
117
+ desc: unmatched text to fetch pattern
118
+ bug: self found
119
+ pdata: |
120
+ foo
121
+ bar
122
+ baz
123
+ plogic: |
124
+ expected: |
125
+ [ "foo\nbar\nbaz\n"]
126
+
127
+
@@ -0,0 +1,32 @@
1
+ ###
2
+ ### $Rev: 117 $
3
+ ### $Release: 3.0.0 $
4
+ ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
+ ###
6
+
7
+ require "#{File.dirname(__FILE__)}/test.rb"
8
+
9
+
10
+ class DirectivesTest < Test::Unit::TestCase
11
+
12
+ ## define test methods
13
+ filename = __FILE__.sub(/\.rb$/, '.yaml')
14
+ load_yaml_testdata_with_each_lang(filename, :langs=>%w[eruby php jstl eperl])
15
+
16
+
17
+ def _test
18
+ #$stderr.puts "*** debug: _test(): @lang=#{@lang.inspect}, @name=#{@name}" if $DEBUG
19
+ regexp = /(\{\{\*|\*\}\})/
20
+ @pdata.gsub!(regexp, '')
21
+ @expected.gsub!(regexp, '') if @expected
22
+ #
23
+ handler = Kwartz::Handler.get_class(@lang).new()
24
+ converter = Kwartz::TextConverter.new(handler)
25
+ stmt_list = converter.convert(@pdata)
26
+ translator = Kwartz::Translator.get_class(@lang).new(:header=>'')
27
+ actual = translator.translate(stmt_list)
28
+ assert_text_equal(@expected, actual)
29
+ end
30
+
31
+
32
+ end
@@ -0,0 +1,1411 @@
1
+ ##
2
+ - name: elem
3
+ subject: elem, Elem, ELEM
4
+ desc: |
5
+ 'elem', 'Elem', and 'ELEM' directive replaces element by expression.
6
+
7
+ 'Elem' directive escapes expression automatically, while 'ELEM' never escape it.
8
+ 'elem' directive escapes expression when command-line option '-e' is specified
9
+ or PROPERTY_ESCAPE is true in configuration file.
10
+
11
+ pdata*:
12
+ eruby: |
13
+ <b {{*title="elem: expr"*}}>foo</b>
14
+ <b {{*title="Elem: expr"*}}>foo</b>
15
+ <b {{*title="ELEM: expr"*}}>foo</b>
16
+
17
+ php: |
18
+ <b {{*title="elem($expr)"*}}>foo</b>
19
+ <b {{*title="Elem($expr)"*}}>foo</b>
20
+ <b {{*title="ELEM($expr)"*}}>foo</b>
21
+
22
+ eperl: |
23
+ <b {{*title="elem($expr)"*}}>foo</b>
24
+ <b {{*title="Elem($expr)"*}}>foo</b>
25
+ <b {{*title="ELEM($expr)"*}}>foo</b>
26
+
27
+ jstl: |
28
+ <b {{*title="elem(expr)"*}}>foo</b>
29
+ <b {{*title="Elem(expr)"*}}>foo</b>
30
+ <b {{*title="ELEM(expr)"*}}>foo</b>
31
+
32
+ expected*:
33
+ eruby: |
34
+ {{*<%= expr %>*}}
35
+ {{*<%=h expr %>*}}
36
+ {{*<%= expr %>*}}
37
+
38
+ php: |
39
+ {{*<?php echo $expr; ?>*}}
40
+ {{*<?php echo htmlspecialchars($expr); ?>*}}
41
+ {{*<?php echo $expr; ?>*}}
42
+
43
+ eperl: |
44
+ {{*<?= $expr !>*}}
45
+ {{*<?= encode_entities($expr) !>*}}
46
+ {{*<?= $expr !>*}}
47
+
48
+ jstl: |
49
+ {{*${expr}*}}
50
+ {{*${expr}*}}
51
+ {{*<c:out value="${expr}" escapeXml="false"/>*}}
52
+
53
+ - name: stag
54
+ subject: stag, Stag, STAG
55
+ desc: |
56
+ 'stag', 'Stag', and 'STAG' directive replaces start-tag by expression.
57
+
58
+ 'Stag' directive escapes expression automatically, while 'STAG' never escape it.
59
+ 'stag' directive escapes expression when command-line option '-e' is specified
60
+ or PROPERTY_ESCAPE is true in configuration file.
61
+
62
+ pdata*:
63
+ eruby: |
64
+ <b {{*title="stag: expr"*}}>foo</b>
65
+ <b {{*title="Stag: expr"*}}>foo</b>
66
+ <b {{*title="STAG: expr"*}}>foo</b>
67
+
68
+ php: |
69
+ <b {{*title="stag($expr)"*}}>foo</b>
70
+ <b {{*title="Stag($expr)"*}}>foo</b>
71
+ <b {{*title="STAG($expr)"*}}>foo</b>
72
+
73
+ eperl: |
74
+ <b {{*title="stag($expr)"*}}>foo</b>
75
+ <b {{*title="Stag($expr)"*}}>foo</b>
76
+ <b {{*title="STAG($expr)"*}}>foo</b>
77
+
78
+ jstl: |
79
+ <b {{*title="stag(expr)"*}}>foo</b>
80
+ <b {{*title="Stag(expr)"*}}>foo</b>
81
+ <b {{*title="STAG(expr)"*}}>foo</b>
82
+
83
+ expected*:
84
+ eruby: |
85
+ {{*<%= expr %>*}}foo</b>
86
+ {{*<%=h expr %>*}}foo</b>
87
+ {{*<%= expr %>*}}foo</b>
88
+
89
+ php: |
90
+ {{*<?php echo $expr; ?>*}}foo</b>
91
+ {{*<?php echo htmlspecialchars($expr); ?>*}}foo</b>
92
+ {{*<?php echo $expr; ?>*}}foo</b>
93
+
94
+ eperl: |
95
+ {{*<?= $expr !>*}}foo</b>
96
+ {{*<?= encode_entities($expr) !>*}}foo</b>
97
+ {{*<?= $expr !>*}}foo</b>
98
+
99
+ jstl: |
100
+ {{*${expr}*}}foo</b>
101
+ {{*${expr}*}}foo</b>
102
+ {{*<c:out value="${expr}" escapeXml="false"/>*}}foo</b>
103
+
104
+ - name: etag
105
+ subject: etag, Etag, ETAG
106
+ desc: |
107
+ 'etag', 'Etag', and 'ETAG' directive replaces start-tag by expression.
108
+
109
+ 'Etag' directive escapes expression automatically, while 'ETAG' never escape it.
110
+ 'etag' directive escapes expression when command-line option '-e' is specified
111
+ or PROPERTY_ESCAPE is true in configuration file.
112
+
113
+ pdata*:
114
+ eruby: |
115
+ <b {{*title="etag: expr"*}}>foo</b>
116
+ <b {{*title="Etag: expr"*}}>foo</b>
117
+ <b {{*title="ETAG: expr"*}}>foo</b>
118
+
119
+ php: |
120
+ <b {{*title="etag($expr)"*}}>foo</b>
121
+ <b {{*title="Etag($expr)"*}}>foo</b>
122
+ <b {{*title="ETAG($expr)"*}}>foo</b>
123
+
124
+ eperl: |
125
+ <b {{*title="etag($expr)"*}}>foo</b>
126
+ <b {{*title="Etag($expr)"*}}>foo</b>
127
+ <b {{*title="ETAG($expr)"*}}>foo</b>
128
+
129
+ jstl: |
130
+ <b {{*title="etag(expr)"*}}>foo</b>
131
+ <b {{*title="Etag(expr)"*}}>foo</b>
132
+ <b {{*title="ETAG(expr)"*}}>foo</b>
133
+
134
+ expected*:
135
+ eruby: |
136
+ <b>foo{{*<%= expr %>*}}
137
+ <b>foo{{*<%=h expr %>*}}
138
+ <b>foo{{*<%= expr %>*}}
139
+
140
+ php: |
141
+ <b>foo{{*<?php echo $expr; ?>*}}
142
+ <b>foo{{*<?php echo htmlspecialchars($expr); ?>*}}
143
+ <b>foo{{*<?php echo $expr; ?>*}}
144
+
145
+ eperl: |
146
+ <b>foo{{*<?= $expr !>*}}
147
+ <b>foo{{*<?= encode_entities($expr) !>*}}
148
+ <b>foo{{*<?= $expr !>*}}
149
+
150
+ jstl: |
151
+ <b>foo{{*${expr}*}}
152
+ <b>foo{{*${expr}*}}
153
+ <b>foo{{*<c:out value="${expr}" escapeXml="false"/>*}}
154
+
155
+ ##
156
+ - name: cont
157
+ subject: cont, Cont, CONT
158
+ desc: |
159
+ 'cont', 'Cont', and 'CONT' directives replace content by expression.
160
+
161
+ 'Cont' directive escapes expression automatically, while 'CONT' never escape it.
162
+ 'cont' directive escapes expression when command-line option '-e' is specified
163
+ or PROPERTY_ESCAPE is true in configuration file.
164
+
165
+ pdata*:
166
+ eruby: |
167
+ <b {{*title="cont: expr"*}}>foo</b>
168
+ <b {{*title="Cont: expr"*}}>foo</b>
169
+ <b {{*title="CONT: expr"*}}>foo</b>
170
+
171
+ php: |
172
+ <b {{*title="cont($expr)"*}}>foo</b>
173
+ <b {{*title="Cont($expr)"*}}>foo</b>
174
+ <b {{*title="CONT($expr)"*}}>foo</b>
175
+
176
+ eperl: |
177
+ <b {{*title="cont($expr)"*}}>foo</b>
178
+ <b {{*title="Cont($expr)"*}}>foo</b>
179
+ <b {{*title="CONT($expr)"*}}>foo</b>
180
+
181
+ jstl: |
182
+ <b {{*title="cont(expr)"*}}>foo</b>
183
+ <b {{*title="Cont(expr)"*}}>foo</b>
184
+ <b {{*title="CONT(expr)"*}}>foo</b>
185
+
186
+ expected*:
187
+ eruby: |
188
+ <b>{{*<%= expr %>*}}</b>
189
+ <b>{{*<%=h expr %>*}}</b>
190
+ <b>{{*<%= expr %>*}}</b>
191
+
192
+ php: |
193
+ <b>{{*<?php echo $expr; ?>*}}</b>
194
+ <b>{{*<?php echo htmlspecialchars($expr); ?>*}}</b>
195
+ <b>{{*<?php echo $expr; ?>*}}</b>
196
+
197
+ eperl: |
198
+ <b>{{*<?= $expr !>*}}</b>
199
+ <b>{{*<?= encode_entities($expr) !>*}}</b>
200
+ <b>{{*<?= $expr !>*}}</b>
201
+
202
+ jstl: |
203
+ <b>{{*${expr}*}}</b>
204
+ <b>{{*${expr}*}}</b>
205
+ <b>{{*<c:out value="${expr}" escapeXml="false"/>*}}</b>
206
+
207
+
208
+ ##
209
+ - name: value
210
+ subject: value, Value, VALUE
211
+ desc: |
212
+ 'value', 'Value', and 'VALUE' directives are equivalent to
213
+ 'cont', 'Cont', and 'CONT' directives respectively.
214
+
215
+ pdata*:
216
+ eruby: |
217
+ <b {{*title="value: expr"*}}>foo</b>
218
+ <b {{*title="Value: expr"*}}>foo</b>
219
+ <b {{*title="VALUE: expr"*}}>foo</b>
220
+
221
+ php: |
222
+ <b {{*title="value($expr)"*}}>foo</b>
223
+ <b {{*title="Value($expr)"*}}>foo</b>
224
+ <b {{*title="VALUE($expr)"*}}>foo</b>
225
+
226
+ eperl: |
227
+ <b {{*title="value($expr)"*}}>foo</b>
228
+ <b {{*title="Value($expr)"*}}>foo</b>
229
+ <b {{*title="VALUE($expr)"*}}>foo</b>
230
+
231
+ jstl: |
232
+ <b {{*title="value(expr)"*}}>foo</b>
233
+ <b {{*title="Value(expr)"*}}>foo</b>
234
+ <b {{*title="VALUE(expr)"*}}>foo</b>
235
+
236
+ expected*:
237
+ eruby: |
238
+ <b>{{*<%= expr %>*}}</b>
239
+ <b>{{*<%=h expr %>*}}</b>
240
+ <b>{{*<%= expr %>*}}</b>
241
+
242
+ php: |
243
+ <b>{{*<?php echo $expr; ?>*}}</b>
244
+ <b>{{*<?php echo htmlspecialchars($expr); ?>*}}</b>
245
+ <b>{{*<?php echo $expr; ?>*}}</b>
246
+
247
+ eperl: |
248
+ <b>{{*<?= $expr !>*}}</b>
249
+ <b>{{*<?= encode_entities($expr) !>*}}</b>
250
+ <b>{{*<?= $expr !>*}}</b>
251
+
252
+ jstl: |
253
+ <b>{{*${expr}*}}</b>
254
+ <b>{{*${expr}*}}</b>
255
+ <b>{{*<c:out value="${expr}" escapeXml="false"/>*}}</b>
256
+
257
+
258
+ ##
259
+ - name: foreach
260
+ subject: foreach
261
+ desc: |
262
+ 'foreach' directive interates element, while 'loop' directive iterates content.
263
+
264
+ pdata*:
265
+ eruby: |
266
+ <tr {{*title="for item in list"*}}>
267
+ <td title="cont item">foo</td>
268
+ </tr>
269
+
270
+ <tr {{*title="for key,value in hash"*}}>
271
+ <td title="cont key">key</td>
272
+ <td title="cont value">value</td>
273
+ </tr>
274
+
275
+ php: |
276
+ <tr {{*title="foreach($list as $item)"*}}>
277
+ <td title="cont($item)">foo</td>
278
+ </tr>
279
+
280
+ <tr {{*title="foreach($hash as $key=>$value)"*}}>
281
+ <td title="cont($key)">key</td>
282
+ <td title="cont($value)">value</td>
283
+ </tr>
284
+
285
+ eperl: |
286
+ <tr {{*title="foreach($item in @list)"*}}>
287
+ <td title="cont($item)">foo</td>
288
+ </tr>
289
+
290
+ <tr {{*title="foreach($key,$value in %hash)"*}}>
291
+ <td title="cont($key)">key</td>
292
+ <td title="cont($value)">value</td>
293
+ </tr>
294
+
295
+ jstl: |
296
+ <tr {{*title="for(item: list)"*}}>
297
+ <td title="cont(item)">foo</td>
298
+ </tr>
299
+
300
+ <tr {{*title="forEach(:var=>'v', :items=>:'params.list', :varStatus=>'status')"*}}>
301
+ <td title="cont(status.index)">1</td>
302
+ <td title="cont(v)"></td>
303
+ </tr>
304
+
305
+ <tr {{*title="forEach(:var=>'n', :begin=>1, :end=>10, :step=>2)"*}}>
306
+ <td title="cont(n)">key</td>
307
+ </tr>
308
+
309
+ expected*:
310
+ eruby: |
311
+ {{*<% for item in list do %>*}}
312
+ <tr>
313
+ <td><%= item %></td>
314
+ </tr>
315
+ {{*<% end %>*}}
316
+
317
+ {{*<% hash.each do |key, value| %>*}}
318
+ <tr>
319
+ <td><%= key %></td>
320
+ <td><%= value %></td>
321
+ </tr>
322
+ {{*<% end %>*}}
323
+
324
+ php: |
325
+ {{*<?php foreach ($list as $item) { ?>*}}
326
+ <tr>
327
+ <td><?php echo $item; ?></td>
328
+ </tr>
329
+ {{*<?php } ?>*}}
330
+
331
+ {{*<?php foreach ($hash as $key=>$value) { ?>*}}
332
+ <tr>
333
+ <td><?php echo $key; ?></td>
334
+ <td><?php echo $value; ?></td>
335
+ </tr>
336
+ {{*<?php } ?>*}}
337
+
338
+ eperl: |
339
+ {{*<? foreach my $item (@list) { !>*}}
340
+ <tr>
341
+ <td><?= $item !></td>
342
+ </tr>
343
+ {{*<? } !>*}}
344
+
345
+ {{*<? foreach my $key (keys %hash) { !>*}}
346
+ {{*<? my $value = $hash{$key}; !>*}}
347
+ <tr>
348
+ <td><?= $key !></td>
349
+ <td><?= $value !></td>
350
+ </tr>
351
+ {{*<? } !>*}}
352
+
353
+ jstl: |
354
+ {{*<c:forEach var="item" items="${list}">*}}
355
+ <tr>
356
+ <td>${item}</td>
357
+ </tr>
358
+ {{*</c:forEach>*}}
359
+
360
+ {{*<c:forEach var="v" items="${params.list}" varStatus="status">*}}
361
+ <tr>
362
+ <td>${status.index}</td>
363
+ <td>${v}</td>
364
+ </tr>
365
+ {{*</c:forEach>*}}
366
+
367
+ {{*<c:forEach var="n" begin="1" end="10" step="2">*}}
368
+ <tr>
369
+ <td>${n}</td>
370
+ </tr>
371
+ {{*</c:forEach>*}}
372
+
373
+
374
+
375
+ - name: list
376
+ subject: list
377
+ desc: |
378
+ 'list' directive interates content, while 'foreach' directive iterates element.
379
+
380
+ pdata*:
381
+ eruby: |
382
+ <tr {{*title="list item in list"*}}>
383
+ <td title="cont item">foo</td>
384
+ </tr>
385
+
386
+ <tr {{*title="list key,value in hash"*}}>
387
+ <td title="cont key">key</td>
388
+ <td title="cont value">value</td>
389
+ </tr>
390
+
391
+ php: |
392
+ <tr {{*title="list($list as $item)"*}}>
393
+ <td title="cont($item)">foo</td>
394
+ </tr>
395
+
396
+ <tr {{*title="list($hash as $key=>$value)"*}}>
397
+ <td title="cont($key)">key</td>
398
+ <td title="cont($value)">value</td>
399
+ </tr>
400
+
401
+ eperl: |
402
+ <tr {{*title="list($item in @list)"*}}>
403
+ <td title="cont($item)">foo</td>
404
+ </tr>
405
+
406
+ <tr {{*title="list($key,$value in %hash)"*}}>
407
+ <td title="cont($key)">key</td>
408
+ <td title="cont($value)">value</td>
409
+ </tr>
410
+
411
+ jstl: |
412
+ <tr {{*title="list(item: list)"*}}>
413
+ <td title="cont(item)">foo</td>
414
+ </tr>
415
+
416
+ expected*:
417
+ eruby: |
418
+ <tr>
419
+ {{*<% for item in list do %>*}}
420
+ <td><%= item %></td>
421
+ {{*<% end %>*}}
422
+ </tr>
423
+
424
+ <tr>
425
+ {{*<% hash.each do |key, value| %>*}}
426
+ <td><%= key %></td>
427
+ <td><%= value %></td>
428
+ {{*<% end %>*}}
429
+ </tr>
430
+
431
+ php: |
432
+ <tr>
433
+ {{*<?php foreach ($list as $item) { ?>*}}
434
+ <td><?php echo $item; ?></td>
435
+ {{*<?php } ?>*}}
436
+ </tr>
437
+
438
+ <tr>
439
+ {{*<?php foreach ($hash as $key=>$value) { ?>*}}
440
+ <td><?php echo $key; ?></td>
441
+ <td><?php echo $value; ?></td>
442
+ {{*<?php } ?>*}}
443
+ </tr>
444
+
445
+ eperl: |
446
+ <tr>
447
+ {{*<? foreach my $item (@list) { !>*}}
448
+ <td><?= $item !></td>
449
+ {{*<? } !>*}}
450
+ </tr>
451
+
452
+ <tr>
453
+ {{*<? foreach my $key (keys %hash) { !>*}}
454
+ {{*<? my $value = $hash{$key}; !>*}}
455
+ <td><?= $key !></td>
456
+ <td><?= $value !></td>
457
+ {{*<? } !>*}}
458
+ </tr>
459
+
460
+ jstl: |
461
+ <tr>
462
+ {{*<c:forEach var="item" items="${list}">*}}
463
+ <td>${item}</td>
464
+ {{*</c:forEach>*}}
465
+ </tr>
466
+
467
+
468
+
469
+ - name: foreach_ctr
470
+ subject: Foreach, List
471
+ desc: |
472
+ 'Foreach' and 'List' directives iterate element or content with loop counter
473
+ (starting with 1).
474
+
475
+ pdata*:
476
+ eruby: |
477
+ <tr {{*title="For item in list"*}}>
478
+ <td title="cont item">foo</td>
479
+ </tr>
480
+
481
+ <tr {{*title="List item in list"*}}>
482
+ <td title="cont item">foo</td>
483
+ </tr>
484
+
485
+ php: |
486
+ <tr {{*title="Foreach($list as $item)"*}}>
487
+ <td title="cont($item)">foo</td>
488
+ </tr>
489
+
490
+ <tr {{*title="List($list as $item)"*}}>
491
+ <td title="cont($item)">foo</td>
492
+ </tr>
493
+
494
+ eperl: |
495
+ <tr {{*title="Foreach($item in @list)"*}}>
496
+ <td title="cont($item)">foo</td>
497
+ </tr>
498
+
499
+ <tr {{*title="List($item in @list)"*}}>
500
+ <td title="cont($item)">foo</td>
501
+ </tr>
502
+
503
+ jstl: |
504
+ <tr {{*title="For(item: list)"*}}>
505
+ <td title="cont(item)">foo</td>
506
+ </tr>
507
+
508
+ <tr {{*title="List(item: list)"*}}>
509
+ <td title="cont(item)">foo</td>
510
+ </tr>
511
+
512
+ expected*:
513
+ eruby: |
514
+ {{*<% item_ctr = 0 %>*}}
515
+ {{*<% for item in list do %>*}}
516
+ {{*<% item_ctr += 1 %>*}}
517
+ <tr>
518
+ <td><%= item %></td>
519
+ </tr>
520
+ {{*<% end %>*}}
521
+
522
+ <tr>
523
+ {{*<% item_ctr = 0 %>*}}
524
+ {{*<% for item in list do %>*}}
525
+ {{*<% item_ctr += 1 %>*}}
526
+ <td><%= item %></td>
527
+ {{*<% end %>*}}
528
+ </tr>
529
+
530
+ php: |
531
+ {{*<?php $item_ctr = 0; ?>*}}
532
+ {{*<?php foreach ($list as $item) { ?>*}}
533
+ {{*<?php $item_ctr++; ?>*}}
534
+ <tr>
535
+ <td><?php echo $item; ?></td>
536
+ </tr>
537
+ {{*<?php } ?>*}}
538
+
539
+ <tr>
540
+ {{*<?php $item_ctr = 0; ?>*}}
541
+ {{*<?php foreach ($list as $item) { ?>*}}
542
+ {{*<?php $item_ctr++; ?>*}}
543
+ <td><?php echo $item; ?></td>
544
+ {{*<?php } ?>*}}
545
+ </tr>
546
+
547
+ eperl: |
548
+ {{*<? my $item_ctr = 0; !>*}}
549
+ {{*<? foreach my $item (@list) { !>*}}
550
+ {{*<? $item_ctr++; !>*}}
551
+ <tr>
552
+ <td><?= $item !></td>
553
+ </tr>
554
+ {{*<? } !>*}}
555
+
556
+ <tr>
557
+ {{*<? my $item_ctr = 0; !>*}}
558
+ {{*<? foreach my $item (@list) { !>*}}
559
+ {{*<? $item_ctr++; !>*}}
560
+ <td><?= $item !></td>
561
+ {{*<? } !>*}}
562
+ </tr>
563
+
564
+ jstl: |
565
+ {{*<c:forEach var="item" items="${list}" varStatus="item_status">*}}
566
+ {{*<c:set var="item_ctr" value="${item_status.count}" />*}}
567
+ <tr>
568
+ <td>${item}</td>
569
+ </tr>
570
+ {{*</c:forEach>*}}
571
+
572
+ <tr>
573
+ {{*<c:forEach var="item" items="${list}" varStatus="item_status">*}}
574
+ {{*<c:set var="item_ctr" value="${item_status.count}" />*}}
575
+ <td>${item}</td>
576
+ {{*</c:forEach>*}}
577
+ </tr>
578
+
579
+
580
+ - name: foreach_tgl
581
+ subject: FOREACH, LIST
582
+ desc: |
583
+ 'FOREACH' and 'LIST' directives iterate element or content with loop counter
584
+ and toggle variable.
585
+ Toggle values are "'odd'" and "'even'" in default.
586
+ You can change them by command-line option '--odd' and '--even'
587
+ or by properties(PROPERTY_ODD, PROPERTY_EVEN) in configuration file.
588
+
589
+ pdata*:
590
+ eruby: |
591
+ <tr {{*title="FOR item in list"*}}>
592
+ <td title="cont item">foo</td>
593
+ </tr>
594
+
595
+ <tr {{*title="LIST item in list"*}}>
596
+ <td title="cont item">foo</td>
597
+ </tr>
598
+
599
+ php: |
600
+ <tr {{*title="FOREACH($list as $item)"*}}>
601
+ <td title="cont($item)">foo</td>
602
+ </tr>
603
+
604
+ <tr {{*title="LIST($list as $item)"*}}>
605
+ <td title="cont($item)">foo</td>
606
+ </tr>
607
+
608
+ eperl: |
609
+ <tr {{*title="FOREACH($item in @list)"*}}>
610
+ <td title="cont($item)">foo</td>
611
+ </tr>
612
+
613
+ <tr {{*title="LIST($item in @list)"*}}>
614
+ <td title="cont($item)">foo</td>
615
+ </tr>
616
+
617
+ jstl: |
618
+ <tr {{*title="FOR(item: list)"*}}>
619
+ <td title="cont(item)">foo</td>
620
+ </tr>
621
+
622
+ <tr {{*title="LIST(item: list)"*}}>
623
+ <td title="cont(item)">foo</td>
624
+ </tr>
625
+
626
+ expected*:
627
+ eruby: |
628
+ {{*<% item_ctr = 0 %>*}}
629
+ {{*<% for item in list do %>*}}
630
+ {{*<% item_ctr += 1 %>*}}
631
+ {{*<% item_tgl = item_ctr%2==0 ? 'even' : 'odd' %>*}}
632
+ <tr>
633
+ <td><%= item %></td>
634
+ </tr>
635
+ {{*<% end %>*}}
636
+
637
+ <tr>
638
+ {{*<% item_ctr = 0 %>*}}
639
+ {{*<% for item in list do %>*}}
640
+ {{*<% item_ctr += 1 %>*}}
641
+ {{*<% item_tgl = item_ctr%2==0 ? 'even' : 'odd' %>*}}
642
+ <td><%= item %></td>
643
+ {{*<% end %>*}}
644
+ </tr>
645
+
646
+ php: |
647
+ {{*<?php $item_ctr = 0; ?>*}}
648
+ {{*<?php foreach ($list as $item) { ?>*}}
649
+ {{*<?php $item_ctr++; ?>*}}
650
+ {{*<?php $item_tgl = $item_ctr%2==0 ? 'even' : 'odd'; ?>*}}
651
+ <tr>
652
+ <td><?php echo $item; ?></td>
653
+ </tr>
654
+ {{*<?php } ?>*}}
655
+
656
+ <tr>
657
+ {{*<?php $item_ctr = 0; ?>*}}
658
+ {{*<?php foreach ($list as $item) { ?>*}}
659
+ {{*<?php $item_ctr++; ?>*}}
660
+ {{*<?php $item_tgl = $item_ctr%2==0 ? 'even' : 'odd'; ?>*}}
661
+ <td><?php echo $item; ?></td>
662
+ {{*<?php } ?>*}}
663
+ </tr>
664
+
665
+ eperl: |
666
+ {{*<? my $item_ctr = 0; !>*}}
667
+ {{*<? foreach my $item (@list) { !>*}}
668
+ {{*<? $item_ctr++; !>*}}
669
+ {{*<? my $item_tgl = $item_ctr%2==0 ? 'even' : 'odd'; !>*}}
670
+ <tr>
671
+ <td><?= $item !></td>
672
+ </tr>
673
+ {{*<? } !>*}}
674
+
675
+ <tr>
676
+ {{*<? my $item_ctr = 0; !>*}}
677
+ {{*<? foreach my $item (@list) { !>*}}
678
+ {{*<? $item_ctr++; !>*}}
679
+ {{*<? my $item_tgl = $item_ctr%2==0 ? 'even' : 'odd'; !>*}}
680
+ <td><?= $item !></td>
681
+ {{*<? } !>*}}
682
+ </tr>
683
+
684
+ jstl: |
685
+ {{*<c:forEach var="item" items="${list}" varStatus="item_status">*}}
686
+ {{*<c:set var="item_ctr" value="${item_status.count}" />*}}
687
+ {{*<c:set var="item_tgl" value="${item_status.count%2==0 ? 'even' : 'odd'}" />*}}
688
+ <tr>
689
+ <td>${item}</td>
690
+ </tr>
691
+ {{*</c:forEach>*}}
692
+
693
+ <tr>
694
+ {{*<c:forEach var="item" items="${list}" varStatus="item_status">*}}
695
+ {{*<c:set var="item_ctr" value="${item_status.count}" />*}}
696
+ {{*<c:set var="item_tgl" value="${item_status.count%2==0 ? 'even' : 'odd'}" />*}}
697
+ <td>${item}</td>
698
+ {{*</c:forEach>*}}
699
+ </tr>
700
+
701
+
702
+ ##
703
+ - name: while
704
+ subject: while, loop
705
+ desc: |
706
+ 'while' and 'loop' directive iterates element or content
707
+ until conditional expression is false.
708
+
709
+ JSTL doesn't support these directives because JSTL doesn't have
710
+ 'while' custom tag.
711
+
712
+ pdata*:
713
+ eruby: |
714
+ <tr {{*title="while (item = dbh.fetch) != nil"*}}>
715
+ <td title="cont item.name">foo</td>
716
+ </tr>
717
+
718
+ <tr {{*title="loop (item = dbh.fetch) != nil"*}}>
719
+ <td title="cont item.name">foo</td>
720
+ </tr>
721
+
722
+ php: |
723
+ <tr {{*title="while(($item = $dbh->fetch()) != null)"*}}>
724
+ <td title="cont($item->name)">foo</td>
725
+ </tr>
726
+
727
+ <tr {{*title="loop(($item = $dbh->fetch()) != null)"*}}>
728
+ <td title="cont($item->name)">foo</td>
729
+ </tr>
730
+
731
+ eperl: |
732
+ <tr {{*title="while(($item = $dbh->fetch()) != null)"*}}>
733
+ <td title="cont($item->name)">foo</td>
734
+ </tr>
735
+
736
+ <tr {{*title="loop(($item = $dbh->fetch()) != null)"*}}>
737
+ <td title="cont($item->name)">foo</td>
738
+ </tr>
739
+
740
+ jstl: |
741
+ *** not supported ***
742
+
743
+ expected*:
744
+ eruby: |
745
+ {{*<% while (item = dbh.fetch) != nil do %>*}}
746
+ <tr>
747
+ <td><%= item.name %></td>
748
+ </tr>
749
+ {{*<% end %>*}}
750
+
751
+ <tr>
752
+ {{*<% while (item = dbh.fetch) != nil do %>*}}
753
+ <td><%= item.name %></td>
754
+ {{*<% end %>*}}
755
+ </tr>
756
+
757
+ php: |
758
+ {{*<?php while (($item = $dbh->fetch()) != null) { ?>*}}
759
+ <tr>
760
+ <td><?php echo $item->name; ?></td>
761
+ </tr>
762
+ {{*<?php } ?>*}}
763
+
764
+ <tr>
765
+ {{*<?php while (($item = $dbh->fetch()) != null) { ?>*}}
766
+ <td><?php echo $item->name; ?></td>
767
+ {{*<?php } ?>*}}
768
+ </tr>
769
+
770
+ eperl: |
771
+ {{*<? while (($item = $dbh->fetch()) != null) { !>*}}
772
+ <tr>
773
+ <td><?= $item->name !></td>
774
+ </tr>
775
+ {{*<? } !>*}}
776
+
777
+ <tr>
778
+ {{*<? while (($item = $dbh->fetch()) != null) { !>*}}
779
+ <td><?= $item->name !></td>
780
+ {{*<? } !>*}}
781
+ </tr>
782
+
783
+ jstl: |
784
+ *** not supported ***
785
+
786
+
787
+
788
+ - name: if
789
+ subject: if-then-else
790
+ desc: |
791
+ 'if', 'elsif'(or 'elseif'), and 'else' directives represent conditional branch.
792
+
793
+ Don't separate with empty lines between end-tag of 'if'/'elseif' directive and
794
+ start-tag of 'elseif'/'else' directive.
795
+
796
+ pdata*:
797
+ eruby: |
798
+ <div {{*title="if status=='error'"*}}>
799
+ <p class="error" title="cont mesg">error</p>
800
+ </div>
801
+ <div {{*title="elsif status=='warning'"*}}>
802
+ <p class="warning" title="cont mesg">waring</p>
803
+ </div>
804
+ <div {{*title="else"*}}>
805
+ <p title="cont mesg">mesg</p>
806
+ </div>
807
+
808
+ php: |
809
+ <div {{*title="if($status=='error')"*}}>
810
+ <p class="error" title="cont($mesg)">error</p>
811
+ </div>
812
+ <div {{*title="elseif($status=='warning')"*}}>
813
+ <p class="warning" title="cont($mesg)">waring</p>
814
+ </div>
815
+ <div {{*title="else"*}}>
816
+ <p title="cont($mesg)">mesg</p>
817
+ </div>
818
+
819
+ eperl: |
820
+ <div {{*title="if($status=='error')"*}}>
821
+ <p class="error" title="cont($mesg)">error</p>
822
+ </div>
823
+ <div {{*title="elsif($status=='warning')"*}}>
824
+ <p class="warning" title="cont($mesg)">waring</p>
825
+ </div>
826
+ <div {{*title="else"*}}>
827
+ <p title="cont($mesg)">mesg</p>
828
+ </div>
829
+
830
+ jstl: |
831
+ <div {{*title="if(status=='error')"*}}>
832
+ <p class="error" title="cont(mesg)">error</p>
833
+ </div>
834
+ <div {{*title="elseif(status=='warning')"*}}>
835
+ <p class="warning" title="cont(mesg)">waring</p>
836
+ </div>
837
+ <div {{*title="else"*}}>
838
+ <p title="cont(mesg)">mesg</p>
839
+ </div>
840
+
841
+ expected*:
842
+ eruby: |
843
+ {{*<% if status=='error' then %>*}}
844
+ <div>
845
+ <p class="error"><%= mesg %></p>
846
+ </div>
847
+ {{*<% elsif status=='warning' then %>*}}
848
+ <div>
849
+ <p class="warning"><%= mesg %></p>
850
+ </div>
851
+ {{*<% else %>*}}
852
+ <div>
853
+ <p><%= mesg %></p>
854
+ </div>
855
+ {{*<% end %>*}}
856
+
857
+ php: |
858
+ {{*<?php if ($status=='error') { ?>*}}
859
+ <div>
860
+ <p class="error"><?php echo $mesg; ?></p>
861
+ </div>
862
+ {{*<?php } elseif ($status=='warning') { ?>*}}
863
+ <div>
864
+ <p class="warning"><?php echo $mesg; ?></p>
865
+ </div>
866
+ {{*<?php } else { ?>*}}
867
+ <div>
868
+ <p><?php echo $mesg; ?></p>
869
+ </div>
870
+ {{*<?php } ?>*}}
871
+
872
+ eperl: |
873
+ {{*<? if ($status=='error') { !>*}}
874
+ <div>
875
+ <p class="error"><?= $mesg !></p>
876
+ </div>
877
+ {{*<? } elsif ($status=='warning') { !>*}}
878
+ <div>
879
+ <p class="warning"><?= $mesg !></p>
880
+ </div>
881
+ {{*<? } else { !>*}}
882
+ <div>
883
+ <p><?= $mesg !></p>
884
+ </div>
885
+ {{*<? } !>*}}
886
+
887
+ jstl: |
888
+ {{*<c:choose><c:when test="${status=='error'}">*}}
889
+ <div>
890
+ <p class="error">${mesg}</p>
891
+ </div>
892
+ {{*</c:when><c:when test="${status=='warning'}">*}}
893
+ <div>
894
+ <p class="warning">${mesg}</p>
895
+ </div>
896
+ {{*</c:when><c:otherwise>*}}
897
+ <div>
898
+ <p>${mesg}</p>
899
+ </div>
900
+ {{*</c:otherwise></c:choose>*}}
901
+
902
+
903
+ ##
904
+ - name: set
905
+ subject: set
906
+ desc: |
907
+ 'set' directive executes any expression.
908
+
909
+ pdata*:
910
+ eruby: |
911
+ <tr {{*title="set color=i%2==0 ? 'red' : 'blue'"*}}>
912
+ <td title="cont: color">red</td>
913
+ </tr>
914
+
915
+ php: |
916
+ <tr {{*title="set($color=$i%2==0 ? 'red' : 'blue')"*}}>
917
+ <td title="cont($color)">red</td>
918
+ </tr>
919
+
920
+ eperl: |
921
+ <tr {{*title="set($color=i%2==0 ? 'red' : 'blue')"*}}>
922
+ <td title="cont($color)">red</td>
923
+ </tr>
924
+
925
+ jstl: |
926
+ <tr {{*title="set(color=i%2==0 ? 'red' : 'blue')"*}}>
927
+ <td title="cont(color)">red</td>
928
+ </tr>
929
+
930
+ expected*:
931
+ eruby: |
932
+ {{*<% color=i%2==0 ? 'red' : 'blue' %>*}}
933
+ <tr>
934
+ <td><%= color %></td>
935
+ </tr>
936
+
937
+ php: |
938
+ {{*<?php $color=$i%2==0 ? 'red' : 'blue'; ?>*}}
939
+ <tr>
940
+ <td><?php echo $color; ?></td>
941
+ </tr>
942
+
943
+ eperl: |
944
+ {{*<? $color=i%2==0 ? 'red' : 'blue'; !>*}}
945
+ <tr>
946
+ <td><?= $color !></td>
947
+ </tr>
948
+
949
+ jstl: |
950
+ {{*<c:set var="color=i%2=" value="${0 ? 'red' : 'blue'}" />*}}
951
+ <tr>
952
+ <td>${color}</td>
953
+ </tr>
954
+
955
+
956
+ ##
957
+ - name: mark
958
+ subject: mark
959
+ desc: |
960
+ 'mark' directive marks the element by name.
961
+ Name is used as selector of ruleset in presentation logic file.
962
+ Id attribute is equivalent to 'mark' directive if other direcitve is not specified.
963
+
964
+ 'mark' directive is language-independent when used with id attribute.
965
+
966
+ pdata*:
967
+ eruby: |
968
+ <ul {{*id="mark:list"*}}>
969
+ <li {{*title="id: item"*}}>foo</li>
970
+ </ul>
971
+
972
+ php: |
973
+ <ul {{*id="mark:list"*}}>
974
+ <li {{*title="id(item)"*}}>foo</li>
975
+ </ul>
976
+
977
+ eperl: |
978
+ <ul {{*id="mark:list"*}}>
979
+ <li {{*title="id(item)"*}}>foo</li>
980
+ </ul>
981
+
982
+ jstl: |
983
+ <ul {{*id="mark:list"*}}>
984
+ <li {{*title="id(item)"*}}>foo</li>
985
+ </ul>
986
+
987
+ expected*:
988
+ eruby: |
989
+ <ul>
990
+ <li>foo</li>
991
+ </ul>
992
+
993
+ php: |
994
+ <ul>
995
+ <li>foo</li>
996
+ </ul>
997
+
998
+ eperl: |
999
+ <ul>
1000
+ <li>foo</li>
1001
+ </ul>
1002
+
1003
+ jstl: |
1004
+ <ul>
1005
+ <li>foo</li>
1006
+ </ul>
1007
+
1008
+
1009
+ ##
1010
+ - name: attr
1011
+ subject: attr, Attr, ATTR
1012
+ desc: |
1013
+ 'attr', 'Attr', and 'ATTR' directives replace attribute value with expression.
1014
+ 'Attr' directive escapes expression automatically, while 'ATTR' never escape it.
1015
+ 'attr' directive escapes expression when command-line option '-e' is specified
1016
+ or PROPERTY_ESCAPE is true in configuration file.
1017
+
1018
+ More than one directives are available in an element with separating by ';',
1019
+ and available with other directive.
1020
+
1021
+ pdata*:
1022
+ eruby: |
1023
+ <tr class="odd"
1024
+ title="FOR v in list; {{*attr: 'class' v_tgl; attr: 'style' style*}}">
1025
+ <td title="cont v.name">foo</td>
1026
+ </tr>
1027
+
1028
+ php: |
1029
+ <tr class="odd"
1030
+ title="FOREACH($list as $v); {{*attr('class',$v_tgl); attr('style',$style)*}}">
1031
+ <td title="cont($v->name)">foo</td>
1032
+ </tr>
1033
+
1034
+ eperl: |
1035
+ <tr class="odd"
1036
+ title="FOREACH($v in @list); {{*attr('class',$v_tgl); attr('style',$style)*}}">
1037
+ <td title="cont($v->name)">foo</td>
1038
+ </tr>
1039
+
1040
+ jstl: |
1041
+ <tr class="odd"
1042
+ title="FOR(v: list); {{*attr('class',v_tgl); attr('style',style)*}}">
1043
+ <td title="cont(v.name)">foo</td>
1044
+ </tr>
1045
+
1046
+ expected*:
1047
+ eruby: |
1048
+ <% v_ctr = 0 %>
1049
+ <% for v in list do %>
1050
+ <% v_ctr += 1 %>
1051
+ <% v_tgl = v_ctr%2==0 ? 'even' : 'odd' %>
1052
+ <tr {{*class="<%= v_tgl %>"*}} {{*style="<%= style %>">*}}
1053
+ <td><%= v.name %></td>
1054
+ </tr>
1055
+ <% end %>
1056
+
1057
+ php: |
1058
+ <?php $v_ctr = 0; ?>
1059
+ <?php foreach ($list as $v) { ?>
1060
+ <?php $v_ctr++; ?>
1061
+ <?php $v_tgl = $v_ctr%2==0 ? 'even' : 'odd'; ?>
1062
+ <tr {{*class="<?php echo $v_tgl; ?>"*}} {{*style="<?php echo $style; ?>"*}}>
1063
+ <td><?php echo $v->name; ?></td>
1064
+ </tr>
1065
+ <?php } ?>
1066
+
1067
+ eperl: |
1068
+ <? my $v_ctr = 0; !>
1069
+ <? foreach my $v (@list) { !>
1070
+ <? $v_ctr++; !>
1071
+ <? my $v_tgl = $v_ctr%2==0 ? 'even' : 'odd'; !>
1072
+ <tr {{*class="<?= $v_tgl !>"*}} {{*style="<?= $style !>"*}}>
1073
+ <td><?= $v->name !></td>
1074
+ </tr>
1075
+ <? } !>
1076
+
1077
+ jstl: |
1078
+ <c:forEach var="v" items="${list}" varStatus="v_status">
1079
+ <c:set var="v_ctr" value="${v_status.count}" />
1080
+ <c:set var="v_tgl" value="${v_status.count%2==0 ? 'even' : 'odd'}" />
1081
+ <tr {{*class="${v_tgl}"*}} {{*style="${style}"*}}>
1082
+ <td>${v.name}</td>
1083
+ </tr>
1084
+ </c:forEach>
1085
+
1086
+
1087
+ ##
1088
+ - name: append
1089
+ subject: append, Append, APPEND
1090
+ desc: |
1091
+ 'append', 'Append', and 'APPEND' directives append expression at the end of start-tag.
1092
+ 'Append' directive escapes expression automatically, while 'APPEND' never escape it.
1093
+ 'append' directive escapes expression when command-line option '-e' is specified
1094
+ or PROPERTY_ESCAPE is true in configuration file.
1095
+
1096
+ More than one directives are available in an element with separating by ';',
1097
+ and available with other directive.
1098
+
1099
+ pdata*:
1100
+ eruby: |
1101
+ <input type="checkbox"
1102
+ {{*title="append: flag1 ? ' checked=\'checked\'' : ''"*}}>
1103
+ # <input type="checkbox" name="flag" value="y"
1104
+ # title="append: flag1 ? ' checked=\'checked\'' : ''">
1105
+
1106
+ php: |
1107
+ <input type="checkbox"
1108
+ {{*title="append($flag1 ? ' checked=\'checked\'' : '')"*}}>
1109
+ # <input type="checkbox" name="flag" value="y"
1110
+ # title="append($flag1 ? ' checked=\'checked\'' : '')">
1111
+
1112
+ eperl: |
1113
+ <input type="checkbox"
1114
+ {{*title="append($flag1 ? ' checked=\'checked\'' : '')"*}}>
1115
+ # <input type="checkbox" name="flag" value="y"
1116
+ # title="append($flag1 ? ' checked=\'checked\'' : '')">
1117
+
1118
+ jstl: |
1119
+ <input type="checkbox"
1120
+ {{*title="append(flag1 ? ' checked=\'checked\'' : '')"*}}>
1121
+ # <input type="checkbox" name="flag" value="y"
1122
+ # title="append(flag1 ? ' checked=\'checked\'' : '')">
1123
+
1124
+ expected*:
1125
+ eruby: |
1126
+ <input type="checkbox"{{*<%= flag1 ? ' checked=\'checked\'' : '' %>*}}>
1127
+ # <input type="checkbox" name="flag" value="y"<%= flag1 ? ' checked=\'checked\'' : '' %>>
1128
+
1129
+ php: |
1130
+ <input type="checkbox"{{*<?php echo $flag1 ? ' checked=\'checked\'' : ''; ?>*}}>
1131
+ # <input type="checkbox" name="flag" value="y"<?php echo $flag1 ? ' checked=\'checked\'' : ''; ?>>
1132
+
1133
+ eperl: |
1134
+ <input type="checkbox"{{*<?= $flag1 ? ' checked=\'checked\'' : '' !>*}}>
1135
+ # <input type="checkbox" name="flag" value="y"<?= $flag1 ? ' checked=\'checked\'' : '' !>>
1136
+
1137
+ jstl: |
1138
+ <input type="checkbox"{{*${flag1 ? ' checked=\'checked\'' : ''}*}}>
1139
+ # <input type="checkbox" name="flag" value="y"${flag1 ? ' checked=\'checked\'' : ''}>
1140
+
1141
+
1142
+
1143
+ ##
1144
+ - name: dummy
1145
+ subject: dummy
1146
+ desc: |
1147
+ 'dummy' directive removes the element.
1148
+ It is very useful when preview the HTML design in browser.
1149
+
1150
+ 'dummy' directive is language-independent when used with id attribute.
1151
+
1152
+ pdata*:
1153
+ eruby: |
1154
+ <ul>
1155
+ <li>foo</li>
1156
+ <li {{*id="dummy:d1"*}}>bar</li>
1157
+ <li {{*title="dummy:"*}}>baz</li>
1158
+ </ul>
1159
+
1160
+ php: |
1161
+ <ul>
1162
+ <li>foo</li>
1163
+ <li {{*id="dummy:d1"*}}>bar</li>
1164
+ <li {{*title="dummy()"*}}>baz</li>
1165
+ </ul>
1166
+
1167
+ eperl: |
1168
+ <ul>
1169
+ <li>foo</li>
1170
+ <li {{*id="dummy:d1"*}}>bar</li>
1171
+ <li {{*title="dummy()"*}}>baz</li>
1172
+ </ul>
1173
+
1174
+ jstl: |
1175
+ <ul>
1176
+ <li>foo</li>
1177
+ <li {{*id="dummy:d1"*}}>bar</li>
1178
+ <li {{*title="dummy()"*}}>baz</li>
1179
+ </ul>
1180
+
1181
+ expected*:
1182
+ eruby: |
1183
+ <ul>
1184
+ <li>foo</li>
1185
+ </ul>
1186
+
1187
+ php: |
1188
+ <ul>
1189
+ <li>foo</li>
1190
+ </ul>
1191
+
1192
+ eperl: |
1193
+ <ul>
1194
+ <li>foo</li>
1195
+ </ul>
1196
+
1197
+ jstl: |
1198
+ <ul>
1199
+ <li>foo</li>
1200
+ </ul>
1201
+
1202
+
1203
+
1204
+ ##
1205
+ - name: default
1206
+ subject: default, Default, DEFAULT
1207
+ desc: |
1208
+ 'default', 'Default', and 'DEFAULT' directive replaces content by expression
1209
+ only if expression is not nil, false, nor empty string.
1210
+
1211
+ 'Default' directive escapes expression automatically, while 'DEFAULT' never escape it.
1212
+ 'default' directive escapes expression when command-line option '-e' is specified
1213
+ or PROPERTY_ESCAPE is true in configuration file.
1214
+
1215
+ pdata*:
1216
+ eruby: |
1217
+ name: <em {{*title="default: user"*}}>Guest</em>
1218
+
1219
+ php: |
1220
+ name: <em {{*title="default($user)"*}}>Guest</em>
1221
+
1222
+ eperl: |
1223
+ name: <em {{*title="default($user)"*}}>Guest</em>
1224
+
1225
+ jstl: |
1226
+ name: <em {{*title="default(user)"*}}>Guest</em>
1227
+
1228
+ expected*:
1229
+ eruby: |
1230
+ name: <em>{{*<% if (user) && !(user).to_s.empty? then %><%= user %><% else %>Guest<% end %>*}}</em>
1231
+
1232
+ php: |
1233
+ name: <em>{{*<?php if ($user) { ?><?php echo $user; ?><?php } else { ?>Guest<?php } ?>*}}</em>
1234
+
1235
+ eperl: |
1236
+ name: <em>{{*<? if ($user) { !><?= $user !><? } else { !>Guest<? } !>*}}</em>
1237
+
1238
+ jstl: |
1239
+ name: <em>{{*<c:out value="${user}" default="Guest" />*}}</em>
1240
+
1241
+
1242
+
1243
+ ##
1244
+ - name: replace
1245
+ common: yes
1246
+ subject: replace_element/content_with_element/content
1247
+ desc: |
1248
+ 'replace_element_with_element', 'replace_element_with_content',
1249
+ 'replace_content_with_element', and 'replace_content_with_content'
1250
+ directives replace element or content with other element or content.
1251
+
1252
+ These directives are language-independent when used with id attribute.
1253
+
1254
+ pdata*:
1255
+ eruby: &replace1_pdata|
1256
+ <div {{*id="mark:link"*}}>
1257
+ back to <a href="/">home</a>.
1258
+ </div>
1259
+
1260
+ <!-- replace element with other element -->
1261
+ <p {{*id="replace_element_with_element:link"*}}>
1262
+ back to home
1263
+ </p>
1264
+
1265
+ <!-- replace element with other content-->
1266
+ <p {{*id="replace_element_with_content:link"*}}>
1267
+ back to home
1268
+ </p>
1269
+
1270
+ <!-- replace content with other element -->
1271
+ <p {{*id="replace_content_with_element:link"*}}>
1272
+ back to home
1273
+ </p>
1274
+
1275
+ <!-- replace content with other content -->
1276
+ <p {{*id="replace_content_with_content:link"*}}>
1277
+ back to home
1278
+ </p>
1279
+
1280
+ php: *replace1_pdata
1281
+
1282
+ eperl: *replace1_pdata
1283
+
1284
+ jstl: *replace1_pdata
1285
+
1286
+ expected*:
1287
+ eruby: &replace1_expected |
1288
+ <div>
1289
+ back to <a href="/">home</a>.
1290
+ </div>
1291
+
1292
+ <!-- replace element with other element -->
1293
+ <div>
1294
+ back to <a href="/">home</a>.
1295
+ </div>
1296
+
1297
+ <!-- replace element with other content-->
1298
+ back to <a href="/">home</a>.
1299
+
1300
+ <!-- replace content with other element -->
1301
+ <p>
1302
+ <div>
1303
+ back to <a href="/">home</a>.
1304
+ </div>
1305
+ </p>
1306
+
1307
+ <!-- replace content with other content -->
1308
+ <p>
1309
+ back to <a href="/">home</a>.
1310
+ </p>
1311
+
1312
+ php: *replace1_expected
1313
+
1314
+ eperl: *replace1_expected
1315
+
1316
+ jstl: *replace1_expected
1317
+
1318
+
1319
+ #- name: replace2
1320
+ # hide: yes
1321
+ # subject: replace_element_with, replace_content_with
1322
+ # desc: |
1323
+ # 'replace_element_with' and 'replace_content_with' directives replace element or content
1324
+ # with other element or content.
1325
+ #
1326
+ # pdata*:
1327
+ # eruby: |
1328
+ # <div {{*id="mark:link"*}}>
1329
+ # back to <a href="/">home</a>.
1330
+ # </div>
1331
+ #
1332
+ # <!-- replace element with other element -->
1333
+ # <p {{*title="replace_element_with: element(link)"*}}>
1334
+ # back to home
1335
+ # </p>
1336
+ #
1337
+ # <!-- replace element with other content-->
1338
+ # <p {{*title="replace_element_with: content(link)"*}}>
1339
+ # back to home
1340
+ # </p>
1341
+ #
1342
+ # <!-- replace content with other element -->
1343
+ # <p {{*title="replace_content_with: element(link)"*}}>
1344
+ # back to home
1345
+ # </p>
1346
+ #
1347
+ # <!-- replace content with other content -->
1348
+ # <p {{*title="replace_content_with: content(link)"*}}>
1349
+ # back to home
1350
+ # </p>
1351
+ #
1352
+ # php: &replace_pdata |
1353
+ # <div title="id(link)">
1354
+ # back to <a href="/">home</a>.
1355
+ # </div>
1356
+ #
1357
+ # <!-- replace element with other element -->
1358
+ # <p title="replace_element_with(element(link))">
1359
+ # back to home
1360
+ # </p>
1361
+ #
1362
+ # <!-- replace element with other content-->
1363
+ # <p title="replace_element_with(content(link))">
1364
+ # back to home
1365
+ # </p>
1366
+ #
1367
+ # <!-- replace content with other element -->
1368
+ # <p title="replace_content_with(element(link))">
1369
+ # back to home
1370
+ # </p>
1371
+ #
1372
+ # <!-- replace content with other content -->
1373
+ # <p title="replace_content_with(content(link))">
1374
+ # back to home
1375
+ # </p>
1376
+ #
1377
+ # eperl: *replace_pdata
1378
+ #
1379
+ # jstl: *replace_pdata
1380
+ #
1381
+ # expected*:
1382
+ # eruby: &expected1 |
1383
+ # <div>
1384
+ # back to <a href="/">home</a>.
1385
+ # </div>
1386
+ #
1387
+ # <!-- replace element with other element -->
1388
+ # <div>
1389
+ # back to <a href="/">home</a>.
1390
+ # </div>
1391
+ #
1392
+ # <!-- replace element with other content-->
1393
+ # back to <a href="/">home</a>.
1394
+ #
1395
+ # <!-- replace content with other element -->
1396
+ # <p>
1397
+ # <div>
1398
+ # back to <a href="/">home</a>.
1399
+ # </div>
1400
+ # </p>
1401
+ #
1402
+ # <!-- replace content with other content -->
1403
+ # <p>
1404
+ # back to <a href="/">home</a>.
1405
+ # </p>
1406
+ #
1407
+ # php: *expected1
1408
+ #
1409
+ # eperl: *expected1
1410
+ #
1411
+ # jstl: *expected1