kwartz 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/CHANGES +444 -0
  2. data/README.txt +4 -1
  3. data/bin/kwartz +2 -2
  4. data/doc-api/classes/Kwartz.html +16 -7
  5. data/doc-api/classes/Kwartz/Assertion.html +6 -6
  6. data/doc-api/classes/Kwartz/AssertionError.html +6 -6
  7. data/doc-api/classes/Kwartz/AttrInfo.html +71 -61
  8. data/doc-api/classes/Kwartz/BaseError.html +12 -12
  9. data/doc-api/classes/Kwartz/BaseTranslator.html +104 -74
  10. data/doc-api/classes/Kwartz/CharacterType.html +24 -24
  11. data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
  12. data/doc-api/classes/Kwartz/CommandOptions.html +50 -50
  13. data/doc-api/classes/Kwartz/Config.html +5 -0
  14. data/doc-api/classes/Kwartz/ConvertError.html +12 -12
  15. data/doc-api/classes/Kwartz/Converter.html +31 -33
  16. data/doc-api/classes/Kwartz/CssStyleParser.html +207 -168
  17. data/doc-api/classes/Kwartz/Defun.html +32 -31
  18. data/doc-api/classes/Kwartz/{HandlerArgument.html → Directive.html} +27 -53
  19. data/doc-api/classes/Kwartz/ElementInfo.html +68 -53
  20. data/doc-api/classes/Kwartz/EperlExpressionParser.html +185 -0
  21. data/doc-api/classes/Kwartz/EperlHandler.html +65 -58
  22. data/doc-api/classes/Kwartz/EperlTranslator.html +14 -7
  23. data/doc-api/classes/Kwartz/ErubisTranslator.html +14 -7
  24. data/doc-api/classes/Kwartz/ErubyTranslator.html +14 -7
  25. data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
  26. data/doc-api/classes/Kwartz/Expander.html +358 -0
  27. data/doc-api/classes/Kwartz/Handler.html +287 -157
  28. data/doc-api/classes/Kwartz/{StatementHelper.html → HandlerHelper.html} +307 -112
  29. data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +23 -23
  30. data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +96 -96
  31. data/doc-api/classes/Kwartz/JstlExpressionParser.html +181 -0
  32. data/doc-api/classes/Kwartz/JstlHandler.html +134 -126
  33. data/doc-api/classes/Kwartz/JstlTranslator.html +21 -14
  34. data/doc-api/classes/Kwartz/KwartzError.html +6 -6
  35. data/doc-api/classes/Kwartz/Main.html +4 -4
  36. data/doc-api/classes/Kwartz/NativeExpression.html +19 -19
  37. data/doc-api/classes/Kwartz/NativeStatement.html +24 -24
  38. data/doc-api/classes/Kwartz/Node.html +7 -7
  39. data/doc-api/classes/Kwartz/PIErubisTranslator.html +21 -14
  40. data/doc-api/classes/Kwartz/ParseError.html +6 -6
  41. data/doc-api/classes/Kwartz/PerlExpressionParser.html +185 -0
  42. data/doc-api/classes/Kwartz/PerlHandler.html +353 -0
  43. data/doc-api/classes/Kwartz/PerlTranslator.html +226 -0
  44. data/doc-api/classes/Kwartz/PhpExpressionParser.html +185 -0
  45. data/doc-api/classes/Kwartz/PhpHandler.html +63 -56
  46. data/doc-api/classes/Kwartz/PhpTranslator.html +21 -14
  47. data/doc-api/classes/Kwartz/PresentationLogicParser.html +126 -123
  48. data/doc-api/classes/Kwartz/PrintStatement.html +18 -18
  49. data/doc-api/classes/Kwartz/RailsHandler.html +84 -85
  50. data/doc-api/classes/Kwartz/RailsTranslator.html +13 -6
  51. data/doc-api/classes/Kwartz/RubyExpressionParser.html +180 -0
  52. data/doc-api/classes/Kwartz/RubyHandler.html +73 -69
  53. data/doc-api/classes/Kwartz/RubyStyleParser.html +86 -86
  54. data/doc-api/classes/Kwartz/RubyTranslator.html +28 -21
  55. data/doc-api/classes/Kwartz/Ruleset.html +622 -1
  56. data/doc-api/classes/Kwartz/StrutsTranslator.html +14 -14
  57. data/doc-api/classes/Kwartz/TagInfo.html +52 -27
  58. data/doc-api/classes/Kwartz/TextConverter.html +75 -37
  59. data/doc-api/classes/Kwartz/Translator.html +54 -53
  60. data/doc-api/classes/Kwartz/Util.html +25 -25
  61. data/doc-api/created.rid +1 -1
  62. data/doc-api/files/__/README_txt.html +7 -2
  63. data/doc-api/files/kwartz/assert_rb.html +2 -2
  64. data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
  65. data/doc-api/files/kwartz/binding/erubis_rb.html +2 -2
  66. data/doc-api/files/kwartz/binding/eruby_rb.html +2 -2
  67. data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
  68. data/doc-api/files/kwartz/binding/perl_rb.html +115 -0
  69. data/doc-api/files/kwartz/binding/php_rb.html +2 -2
  70. data/doc-api/files/kwartz/binding/pierubis_rb.html +2 -2
  71. data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
  72. data/doc-api/files/kwartz/binding/ruby_rb.html +2 -2
  73. data/doc-api/files/kwartz/binding/struts_rb.html +2 -2
  74. data/doc-api/files/kwartz/config_rb.html +2 -2
  75. data/doc-api/files/kwartz/converter_rb.html +2 -2
  76. data/doc-api/files/kwartz/defun_rb.html +2 -2
  77. data/doc-api/files/kwartz/error_rb.html +2 -2
  78. data/doc-api/files/kwartz/helper/rails_rb.html +2 -2
  79. data/doc-api/files/kwartz/main_rb.html +3 -2
  80. data/doc-api/files/kwartz/node_rb.html +2 -2
  81. data/doc-api/files/kwartz/parser_rb.html +2 -2
  82. data/doc-api/files/kwartz/translator_rb.html +2 -2
  83. data/doc-api/files/kwartz/util/assert-text-equal_rb.html +2 -2
  84. data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
  85. data/doc-api/files/kwartz/util_rb.html +2 -2
  86. data/doc-api/files/kwartz_rb.html +2 -2
  87. data/doc-api/fr_class_index.html +10 -5
  88. data/doc-api/fr_file_index.html +1 -0
  89. data/doc-api/fr_method_index.html +268 -239
  90. data/doc/docstyle.css +9 -3
  91. data/doc/img/fig05.png +0 -0
  92. data/doc/introduction-to-kwartz.html +3040 -0
  93. data/doc/pattern-catalog.html +5 -3
  94. data/doc/reference.html +680 -26
  95. data/doc/users-guide.html +222 -67
  96. data/kwartz.gemspec +4 -4
  97. data/lib/kwartz.rb +3 -3
  98. data/lib/kwartz/assert.rb +2 -2
  99. data/lib/kwartz/binding/eperl.rb +71 -31
  100. data/lib/kwartz/binding/erubis.rb +3 -2
  101. data/lib/kwartz/binding/eruby.rb +3 -2
  102. data/lib/kwartz/binding/jstl.rb +66 -29
  103. data/lib/kwartz/binding/perl.rb +230 -0
  104. data/lib/kwartz/binding/php.rb +69 -29
  105. data/lib/kwartz/binding/pierubis.rb +3 -2
  106. data/lib/kwartz/binding/rails.rb +18 -18
  107. data/lib/kwartz/binding/ruby.rb +74 -42
  108. data/lib/kwartz/binding/struts.rb +22 -21
  109. data/lib/kwartz/config.rb +4 -4
  110. data/lib/kwartz/converter.rb +465 -345
  111. data/lib/kwartz/defun.rb +2 -2
  112. data/lib/kwartz/error.rb +2 -2
  113. data/lib/kwartz/helper/rails.rb +2 -2
  114. data/lib/kwartz/main.rb +5 -4
  115. data/lib/kwartz/node.rb +92 -144
  116. data/lib/kwartz/parser.rb +112 -103
  117. data/lib/kwartz/translator.rb +14 -6
  118. data/lib/kwartz/util.rb +2 -2
  119. data/lib/kwartz/util/assert-text-equal.rb +2 -2
  120. data/lib/kwartz/util/testcase-helper.rb +1 -1
  121. data/test/test-compile.rb +2 -2
  122. data/test/test-compile.yaml +81 -0
  123. data/test/test-converter.rb +4 -8
  124. data/test/test-converter.yaml +152 -3
  125. data/test/test-directives.rb +2 -2
  126. data/test/test-directives.yaml +222 -0
  127. data/test/test-main.rb +6 -4
  128. data/test/test-main.yaml +66 -1
  129. data/test/test-parser.rb +12 -3
  130. data/test/test-parser.yaml +64 -51
  131. data/test/test-rails.rb +2 -2
  132. data/test/test-ruleset.rb +2 -2
  133. data/test/test-ruleset.yaml +465 -4
  134. data/test/test.log +6 -0
  135. data/test/test.rb +2 -2
  136. metadata +116 -106
  137. data/ChangeLog +0 -156
  138. data/doc-api/classes/Kwartz/DocumentRuleset.html +0 -369
  139. data/doc-api/classes/Kwartz/ElementExpander.html +0 -325
  140. data/doc-api/classes/Kwartz/ElementRuleset.html +0 -612
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 136 $
3
- ### $Release: 3.1.2 $
2
+ ### $Rev$
3
+ ### $Release: 3.2.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -21,7 +21,9 @@ YAML_DATA = ydoc['yamldata']
21
21
  YAML_OUTPUT = ydoc['yamloutput']
22
22
  NOTEXT_ERUBY = ydoc['notext*']['eruby']
23
23
  NOTEXT_RUBY = ydoc['notext*']['ruby']
24
- DEFUN_ERUBY = ydoc['defun*']['eruby']
24
+ #DEFUN_ERUBY = ydoc['defun*']['eruby']
25
+ key = RUBY_VERSION >= '1.9' ? 'eruby19' : RUBY_VERSION >= '1.8.7' ? 'eruby187' : 'eruby186'
26
+ DEFUN_ERUBY = ydoc['defun*'][key]
25
27
  DEFUN_PHP = ydoc['defun*']['php']
26
28
 
27
29
  class File
@@ -39,7 +41,7 @@ class MainTest < Test::Unit::TestCase
39
41
 
40
42
 
41
43
  def _test
42
- @name = (caller()[0] =~ /in `test_(.*?)'/) && $1
44
+ @name = (caller()[0] =~ /in `(?:block in )?test_(.*?)'/) && $1
43
45
  return if ENV['TEST'] && ENV['TEST'] != @name
44
46
  begin
45
47
  File.write("#{@name}.pdata", @pdata) if @pdata
@@ -175,7 +175,7 @@ yamloutput: |
175
175
  </html>
176
176
 
177
177
  defun*:
178
- eruby: |
178
+ eruby186: |
179
179
  module View
180
180
 
181
181
  (@@proc_table ||= {})['defun1'] = proc do
@@ -207,6 +207,71 @@ defun*:
207
207
 
208
208
  end
209
209
 
210
+ eruby187: |
211
+ module View
212
+
213
+ (@@proc_table ||= {})['defun1'] = proc do
214
+ _erbout = ''; _erbout.concat "<html>\n"
215
+ ; _erbout.concat " <body>\n"
216
+ ; _erbout.concat " <h1>"; _erbout.concat(( @title ).to_s); _erbout.concat "</h1>\n"
217
+ ; _erbout.concat " <table id=\"content\">\n"
218
+ ; for item in @list
219
+ _erbout.concat " <tr>\n"
220
+ ; _erbout.concat " <td>"; _erbout.concat((h item ).to_s); _erbout.concat "</td>\n"
221
+ ; _erbout.concat " </tr>\n"
222
+ ; end
223
+ _erbout.concat " </table>\n"
224
+ ; _erbout.concat " </body>\n"
225
+ ; _erbout.concat "</html>\n"
226
+ ; _erbout
227
+ end#proc
228
+
229
+ module_function
230
+ def expand_defun1(context={})
231
+ if context.is_a?(Hash)
232
+ hash = context
233
+ context = Object.new
234
+ hash.each { |key, val| context.instance_variable_set("@#{key}", val) }
235
+ end
236
+ proc_obj = @@proc_table['defun1']
237
+ context.instance_eval(&proc_obj)
238
+ end
239
+
240
+ end
241
+
242
+ eruby19: |
243
+ module View
244
+
245
+ (@@proc_table ||= {})['defun1'] = proc do
246
+ #coding:US-ASCII
247
+ _erbout = ''; _erbout.concat "<html>\n"
248
+ ; _erbout.concat " <body>\n"
249
+ ; _erbout.concat " <h1>"; _erbout.concat(( @title ).to_s); _erbout.concat "</h1>\n"
250
+ ; _erbout.concat " <table id=\"content\">\n"
251
+ ; for item in @list
252
+ _erbout.concat " <tr>\n"
253
+ ; _erbout.concat " <td>"; _erbout.concat((h item ).to_s); _erbout.concat "</td>\n"
254
+ ; _erbout.concat " </tr>\n"
255
+ ; end
256
+ _erbout.concat " </table>\n"
257
+ ; _erbout.concat " </body>\n"
258
+ ; _erbout.concat "</html>\n"
259
+ ; _erbout.force_encoding(__ENCODING__)
260
+ end#proc
261
+
262
+ module_function
263
+ def expand_defun1(context={})
264
+ if context.is_a?(Hash)
265
+ hash = context
266
+ context = Object.new
267
+ hash.each { |key, val| context.instance_variable_set("@#{key}", val) }
268
+ end
269
+ proc_obj = @@proc_table['defun1']
270
+ context.instance_eval(&proc_obj)
271
+ end
272
+
273
+ end
274
+
210
275
  php: |
211
276
  <?php
212
277
  function print_view_defun2($context) {
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 122 $
3
- ### $Release: 3.1.2 $
2
+ ### $Rev$
3
+ ### $Release: 3.2.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -25,7 +25,8 @@ class ParserTest < Test::Unit::TestCase
25
25
  def __test
26
26
  case @style
27
27
  when 'ruby'
28
- parser = Kwartz::RubyStyleParser.new()
28
+ #parser = Kwartz::RubyStyleParser.new()
29
+ return
29
30
  when 'css'
30
31
  parser = Kwartz::CssStyleParser.new()
31
32
  else
@@ -34,9 +35,17 @@ class ParserTest < Test::Unit::TestCase
34
35
  if @name =~ /scan/
35
36
  actual = ''
36
37
  parser.__send__ :reset, @plogic
38
+ ctr = 0
37
39
  while (ret = parser.scan()) != nil
38
40
  actual << "#{parser.linenum}:#{parser.column}:"
39
41
  actual << " token=#{parser.token.inspect}, value=#{parser.value.inspect}\n"
42
+ if parser.token == :'{'
43
+ ctr += 1
44
+ parser.mode = :declaration if ctr == 1
45
+ elsif parser.token == :'}'
46
+ ctr -= 1
47
+ parser.mode = :selector if ctr == 0
48
+ end
40
49
  break if ret == :error
41
50
  end
42
51
  else
@@ -1,5 +1,5 @@
1
- ## $Rev: 132 $
2
- ## $Release: 3.1.2 $
1
+ ## $Rev$
2
+ ## $Release: 3.2.0 $
3
3
  ## copyright(c) 2004-2006 kuwata-lab.com all rights reserved
4
4
 
5
5
  ###
@@ -16,8 +16,7 @@
16
16
  }
17
17
  expected*:
18
18
  ruby: |
19
- 2:2: token=35, value="#"
20
- 2:6: token=:ident, value="list"
19
+ 2:6: token=:selector, value="#list"
21
20
  2:8: token=:"{", value="{"
22
21
  3:8: token=:value, value="value"
23
22
  4:8: token=:attrs, value="attrs"
@@ -26,6 +25,16 @@
26
25
  6:10: token=:"{", value="{"
27
26
  7:4: token=:"}", value="}"
28
27
  8:2: token=:"}", value="}"
28
+ # 2:2: token=35, value="#"
29
+ # 2:6: token=:ident, value="list"
30
+ # 2:8: token=:"{", value="{"
31
+ # 3:8: token=:value, value="value"
32
+ # 4:8: token=:attrs, value="attrs"
33
+ # 5:9: token=:append, value="append"
34
+ # 6:8: token=:logic, value="logic"
35
+ # 6:10: token=:"{", value="{"
36
+ # 7:4: token=:"}", value="}"
37
+ # 8:2: token=:"}", value="}"
29
38
  php: |
30
39
  2:2: token=#, value="#"
31
40
  2:6: token=:ident, value="list"
@@ -68,7 +77,7 @@
68
77
  #list {
69
78
  }
70
79
  expected: &elem1|
71
- - name: list
80
+ - selectors: ["#list"]
72
81
 
73
82
  - name: parse_elem1_ruby
74
83
  style: ruby
@@ -86,7 +95,7 @@
86
95
  value: @user['name'];
87
96
  }
88
97
  expected: &value1|
89
- - name: list
98
+ - selectors: ["#list"]
90
99
  cont: @user['name']
91
100
 
92
101
  - name: parse_value_part1_ruby
@@ -107,7 +116,7 @@
107
116
  'color' @prop[:color];
108
117
  }
109
118
  expected: &attrs1|
110
- - name: list
119
+ - selectors: ["#list"]
111
120
  attrs:
112
121
  - name: class
113
122
  value: @class
@@ -134,11 +143,11 @@
134
143
  append: aaa, bbb,ccc;
135
144
  }
136
145
  expected: &append1|
137
- - name: list1
146
+ - selectors: ["#list1"]
138
147
  append:
139
148
  - @name==item['name'] ? " checked='checked'" : ''
140
149
  - chk(@name)
141
- - name: list2
150
+ - selectors: ["#list2"]
142
151
  append:
143
152
  - aaa, bbb,ccc
144
153
 
@@ -152,11 +161,11 @@
152
161
  append aaa, bbb,ccc
153
162
  }
154
163
  expected: |
155
- - name: list1
164
+ - selectors: ["#list1"]
156
165
  append:
157
166
  - @name==item['name'] ? " checked='checked'" : ''
158
167
  - chk(@name)
159
- - name: list2
168
+ - selectors: ["#list2"]
160
169
  append:
161
170
  - aaa
162
171
  - bbb,ccc
@@ -169,7 +178,7 @@
169
178
  remove: "foo", "bar", 'baz';
170
179
  }
171
180
  expected: &remove1|
172
- - name: list
181
+ - selectors: ["#list"]
173
182
  remove:
174
183
  - foo
175
184
  - bar
@@ -191,7 +200,7 @@
191
200
  tagname: 'html:html';
192
201
  }
193
202
  expected: &tagname1|
194
- - name: list
203
+ - selectors: ["#list"]
195
204
  tagname: html:html
196
205
 
197
206
  - name: parse_tagname_part1_ruby
@@ -216,7 +225,7 @@
216
225
  }
217
226
  }
218
227
  expected: &logic1|
219
- - name: list
228
+ - selectors: ["#list"]
220
229
  logic:
221
230
  - <% @list.each { |item|%>
222
231
  - _stag
@@ -254,7 +263,7 @@
254
263
  }
255
264
  }
256
265
  expected: &logic2|
257
- - name: list
266
+ - selectors: ["#list"]
258
267
  logic:
259
268
  - <% @list.each_with_index { |item, i|%>
260
269
  - <% if i % 2 == 0%>
@@ -280,6 +289,25 @@
280
289
  }
281
290
  expected: *logic2
282
291
 
292
+ ###
293
+ - name: parse_beforeafter_css
294
+ style: css
295
+ plogic: |
296
+ #list {
297
+ before: {
298
+ print "-- start --\n"
299
+ }
300
+ after: {
301
+ print "-- end --\n"
302
+ }
303
+ }
304
+ expected: |
305
+ - selectors: ["#list"]
306
+ before:
307
+ - print(<%="-- start --\n"%>)
308
+ after:
309
+ - print(<%="-- end --\n"%>)
310
+
283
311
  ###
284
312
  - name: parse_import_command1_css
285
313
  style: css
@@ -289,7 +317,7 @@
289
317
  value: item;
290
318
  }
291
319
  expected: |
292
- - name: page_link
320
+ - selectors: ["#page_link"]
293
321
  cont: page.label
294
322
  attrs:
295
323
  - name: href
@@ -298,7 +326,7 @@
298
326
  - <% if page%>
299
327
  - _elem
300
328
  - <% end%>
301
- - name: item
329
+ - selectors: ["#item"]
302
330
  cont: item
303
331
  setup*:
304
332
  ruby: |
@@ -339,7 +367,7 @@
339
367
  - name: parse_multi_selector_css
340
368
  style: css
341
369
  plogic: |
342
- #item1, #item2, #item3 {
370
+ #id, .class, tag::name {
343
371
  value: $item;
344
372
  logic: {
345
373
  foreach ($list as $item) {
@@ -350,23 +378,7 @@
350
378
  }
351
379
  }
352
380
  expected: |
353
- - name: item1
354
- cont: $item
355
- logic:
356
- - <% foreach ($list as $item) {%>
357
- - _stag
358
- - _cont
359
- - _etag
360
- - <% }%>
361
- - name: item2
362
- cont: $item
363
- logic:
364
- - <% foreach ($list as $item) {%>
365
- - _stag
366
- - _cont
367
- - _etag
368
- - <% }%>
369
- - name: item3
381
+ - selectors: ["#id", ".class", "tag::name"]
370
382
  cont: $item
371
383
  logic:
372
384
  - <% foreach ($list as $item) {%>
@@ -380,8 +392,6 @@
380
392
  style: css
381
393
  plogic: |
382
394
  #DOCUMENT {
383
- local: i, item, title, list;
384
- global: _context;
385
395
  begin: {
386
396
  title = _context[:title]
387
397
  list = _context[:list]
@@ -393,23 +403,26 @@
393
403
  end
394
404
  }
395
405
  }
406
+ # local: i, item, title, list;
407
+ # global: _context;
396
408
  expected: |
397
- - name: DOCUMENT
398
- global:
399
- - _context
400
- local:
401
- - i
402
- - item
403
- - title
404
- - list
405
- begin:
409
+ - selectors: ["#DOCUMENT"]
410
+ before:
406
411
  - <% title = _context[:title]%>
407
412
  - <% list = _context[:list]%>
408
- end:
413
+ after:
409
414
  - print(<%="*** debug:\n"%>)
410
415
  - <% _context.each do |key, value|%>
411
416
  - print(<%="*** key=#{key}, value=#{value.inspect}"%>)
412
417
  - <% end%>
418
+ # global:
419
+ # - _context
420
+ # local:
421
+ # - i
422
+ # - item
423
+ # - title
424
+ # - list
425
+
413
426
  ###
414
427
  - name: parse_comment1_css
415
428
  style: css
@@ -423,7 +436,7 @@
423
436
  }
424
437
  /* tail comment may cause parse error! */
425
438
  expected: |
426
- - name: foo
439
+ - selectors: ["#foo"]
427
440
  cont: foo
428
441
 
429
442
  - name: parse_comment2_css
@@ -444,7 +457,7 @@
444
457
  }
445
458
  }
446
459
  expected: |
447
- - name: foo
460
+ - selectors: ["#foo"]
448
461
  cont: item
449
462
  logic:
450
463
  - _elem
@@ -475,7 +488,7 @@
475
488
  }
476
489
  }
477
490
  expected: &all1 |
478
- - name: item
491
+ - selectors: ["#item"]
479
492
  stag: start_link_tag('user', 'name')
480
493
  cont: $item
481
494
  etag: end_link()
@@ -524,7 +537,7 @@
524
537
  }
525
538
  }
526
539
  expected: |
527
- - name: item
540
+ - selectors: ["#item"]
528
541
  stag: start_link_tag('user', 'name')
529
542
  cont: item
530
543
  etag: end_link()
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 114 $
3
- ### $Release: 3.1.2 $
2
+ ### $Rev$
3
+ ### $Release: 3.2.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -1,6 +1,6 @@
1
1
  ###
2
- ### $Rev: 117 $
3
- ### $Release: 3.1.2 $
2
+ ### $Rev$
3
+ ### $Release: 3.2.0 $
4
4
  ### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
5
5
  ###
6
6
 
@@ -652,14 +652,303 @@
652
652
  {{*<? } !>*}}
653
653
  </ul>
654
654
 
655
+ ###
656
+ - name: before
657
+ title: before, after
658
+ desc: |
659
+ {{,before:,}} and {{,after:,}} property represents the prework and postwork
660
+ of each element's presentation logics.
661
+ These properties enables to share or reuse presentation logics.
662
+ .#These properties takes target code block and are available only with
663
+ .#'#DOCUMENT' selector.
664
+
665
+ pdata: |
666
+ <!-- Groups -->
667
+ <ul id="mark:groups">
668
+ <li class="item"></li>
669
+ </ul>
670
+
671
+ <!-- Members -->
672
+ <ol id="mark:members">
673
+ <li class="item"></li>
674
+ </ol>
675
+
676
+ plogic*:
677
+ eruby: |
678
+ #groups {
679
+ {{*before:*}} {
680
+ {{*list = @groups*}}
681
+ }
682
+ {{*after:*}} {
683
+ {{*group_count = count*}}
684
+ }
685
+ }
686
+ #members {
687
+ {{*before:*}} {
688
+ {{*list = @members*}}
689
+ }
690
+ {{*after:*}} {
691
+ {{*member_count = count*}}
692
+ }
693
+ }
694
+
695
+ /* common 'logic:' part */
696
+ #groups, #members {
697
+ logic: {
698
+ count = 0
699
+ _stag
700
+ for item in list
701
+ unless item.obsolete?
702
+ count += 1
703
+ _cont
704
+ end
705
+ end
706
+ _etag
707
+ }
708
+ }
709
+
710
+ .item {
711
+ value: item.name;
712
+ }
713
+
714
+ php: |
715
+ #groups {
716
+ {{*before:*}} {
717
+ {{*$list = $groups;*}}
718
+ }
719
+ {{*after:*}} {
720
+ {{*$group_count = $count;*}}
721
+ }
722
+ }
723
+ #members {
724
+ {{*before:*}} {
725
+ {{*$list = $members;*}}
726
+ }
727
+ {{*after:*}} {
728
+ {{*$member_count = $count;*}}
729
+ }
730
+ }
731
+
732
+ /* common 'logic:' part */
733
+ #groups, #members {
734
+ logic: {
735
+ $count = 0;
736
+ _stag();
737
+ foreach ($list as $item) {
738
+ if (! $item->obsolete) {
739
+ $count++;
740
+ _cont();
741
+ }
742
+ }
743
+ _etag();
744
+ }
745
+ }
746
+
747
+ .item {
748
+ value: $item->name;
749
+ }
750
+
751
+ jstl: |
752
+ #groups {
753
+ {{*before:*}} {
754
+ {{*<c:set var="list" value="${groups}" />*}}
755
+ }
756
+ {{*after:*}} {
757
+ {{*<c:set var="group_count" value="${count}" />*}}
758
+ }
759
+ }
760
+ #members {
761
+ {{*before:*}} {
762
+ {{*<c:set var="list" value="${members}" />*}}
763
+ }
764
+ {{*after:*}} {
765
+ {{*<c:set var="members_count" value="${count}" />*}}
766
+ }
767
+ }
768
+
769
+ /* common 'logic:' part */
770
+ #groups, #members {
771
+ logic: {
772
+ <c:set var="count" value="${0}" />
773
+ _stag()
774
+ <c:forEach var="item" items="${list}" />
775
+ <c:if test="${not item.obsolete}" />
776
+ <c:set var="count" value="${count+1}" />
777
+ _cont()
778
+ </c:if>
779
+ </c:forEach>
780
+ _etag()
781
+ }
782
+ }
783
+
784
+ .item {
785
+ value: item.name;
786
+ }
787
+
788
+ eperl: |
789
+ #groups {
790
+ {{*before:*}} {
791
+ {{*@list = @groups;*}}
792
+ }
793
+ {{*after:*}} {
794
+ {{*$group_count = $count;*}}
795
+ }
796
+ }
797
+ #members {
798
+ {{*before:*}} {
799
+ {{*@list = @members;*}}
800
+ }
801
+ {{*after:*}} {
802
+ {{*$member_count = $count;*}}
803
+ }
804
+ }
805
+
806
+ /* common 'logic:' part */
807
+ #groups, #members {
808
+ logic: {
809
+ $count = 0;
810
+ _stag();
811
+ foreach $item (@list) {
812
+ if (! $item['obsolete']) {
813
+ $count++;
814
+ _cont();
815
+ }
816
+ }
817
+ _etag();
818
+ }
819
+ }
820
+
821
+ .item {
822
+ value: $item['name'];
823
+ }
824
+
825
+ expected*:
826
+ eruby: |
827
+ <!-- Groups -->
828
+ <% {{*list = @groups*}} %>
829
+ <% count = 0 %>
830
+ <ul>
831
+ <% for item in list %>
832
+ <% unless item.obsolete? %>
833
+ <% count += 1 %>
834
+ <li class="item"><%= item.name %></li>
835
+ <% end %>
836
+ <% end %>
837
+ </ul>
838
+ <% {{*group_count = count*}} %>
839
+
840
+ <!-- Members -->
841
+ <% {{*list = @members*}} %>
842
+ <% count = 0 %>
843
+ <ol>
844
+ <% for item in list %>
845
+ <% unless item.obsolete? %>
846
+ <% count += 1 %>
847
+ <li class="item"><%= item.name %></li>
848
+ <% end %>
849
+ <% end %>
850
+ </ol>
851
+ <% {{*member_count = count*}} %>
852
+
853
+ php: |
854
+ <!-- Groups -->
855
+ <?php {{*$list = $groups;*}} ?>
856
+ <?php $count = 0; ?>
857
+ <ul>
858
+ <?php foreach ($list as $item) { ?>
859
+ <?php if (! $item->obsolete) { ?>
860
+ <?php $count++; ?>
861
+ <li class="item"><?php echo $item->name; ?></li>
862
+ <?php } ?>
863
+ <?php } ?>
864
+ </ul>
865
+ <?php {{*$group_count = $count;*}} ?>
866
+
867
+ <!-- Members -->
868
+ <?php {{*$list = $members;*}} ?>
869
+ <?php $count = 0; ?>
870
+ <ol>
871
+ <?php foreach ($list as $item) { ?>
872
+ <?php if (! $item->obsolete) { ?>
873
+ <?php $count++; ?>
874
+ <li class="item"><?php echo $item->name; ?></li>
875
+ <?php } ?>
876
+ <?php } ?>
877
+ </ol>
878
+ <?php {{*$member_count = $count;*}} ?>
879
+
880
+ jstl: |
881
+ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
882
+ <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
883
+ <!-- Groups -->
884
+ {{*<c:set var="list" value="${groups}" />*}}
885
+ <c:set var="count" value="${0}" />
886
+ <ul>
887
+ <c:forEach var="item" items="${list}" />
888
+ <c:if test="${not item.obsolete}" />
889
+ <c:set var="count" value="${count+1}" />
890
+ <li class="item">${item.name}</li>
891
+ </c:if>
892
+ </c:forEach>
893
+ </ul>
894
+ {{*<c:set var="group_count" value="${count}" />*}}
895
+
896
+ <!-- Members -->
897
+ {{*<c:set var="list" value="${members}" />*}}
898
+ <c:set var="count" value="${0}" />
899
+ <ol>
900
+ <c:forEach var="item" items="${list}" />
901
+ <c:if test="${not item.obsolete}" />
902
+ <c:set var="count" value="${count+1}" />
903
+ <li class="item">${item.name}</li>
904
+ </c:if>
905
+ </c:forEach>
906
+ </ol>
907
+ {{*<c:set var="members_count" value="${count}" />*}}
908
+
909
+ eperl: |
910
+ <!-- Groups -->
911
+ <? {{*@list = @groups;*}} !>
912
+ <? $count = 0; !>
913
+ <ul>
914
+ <? foreach $item (@list) { !>
915
+ <? if (! $item['obsolete']) { !>
916
+ <? $count++; !>
917
+ <li class="item"><?= $item['name'] !></li>
918
+ <? } !>
919
+ <? } !>
920
+ </ul>
921
+ <? {{*$group_count = $count;*}} !>
922
+
923
+ <!-- Members -->
924
+ <? {{*@list = @members;*}} !>
925
+ <? $count = 0; !>
926
+ <ol>
927
+ <? foreach $item (@list) { !>
928
+ <? if (! $item['obsolete']) { !>
929
+ <? $count++; !>
930
+ <li class="item"><?= $item['name'] !></li>
931
+ <? } !>
932
+ <? } !>
933
+ </ol>
934
+ <? {{*$member_count = $count;*}} !>
935
+
936
+
655
937
  ###
656
938
  - name: begin
657
939
  title: begin, end
658
940
  desc: |
659
- {{,begin:,}} and {{,end:,}} property represents the prework and postwork
660
- of document respectively.
661
- These properties takes target code block and are available only with
662
- '#DOCUMENT' selector.
941
+ {{,begin:,}} and {{,end:,}} properties are equal to {{,before:,}} and {{,after:,}}.
942
+ {{*These are obsolete and leaved for compatibility*}}.
943
+
944
+ {{,begin:,}} and {{,end:,}} were aimed to add prework and postwork of document,
945
+ and restricted to be available only with '#DOCUMENT' selector.
946
+ Currently {{,before:,}} and {{,after:,}} are available with '#DOCUMENT' selector,
947
+ so you should use these properties instead of {{,begin:,}} and {{,end:,}}.
948
+ .#{{,begin:,}} and {{,end:,}} property represents the prework and postwork
949
+ .#of document respectively.
950
+ .#These properties takes target code block and are available only with
951
+ .#'#DOCUMENT' selector.
663
952
 
664
953
  pdata: |
665
954
  <p>Hello <span id="mark:username">world</span>!</p>
@@ -796,3 +1085,175 @@
796
1085
  <? } !>
797
1086
  </ul>
798
1087
  {{*<?= "<!-- document end -->\n" !>*}}
1088
+
1089
+
1090
+ ###
1091
+ - name: attrvar
1092
+ title: Attribute Variable
1093
+ desc: |
1094
+ Attribute variable is a notation such as '$(attrname)' which represents attribute value.
1095
+ Attribute variable allows presentation logic to refer attribute value in presentation data.
1096
+
1097
+ pdata: |
1098
+ <form action="create" {{*method="post"*}}>
1099
+ Username: <input type="text" id="comment_username" {{*size="30"*}}><br>
1100
+ Comment: <textarea id="comment_text" {{*rows="3"*}} {{*cols="50"*}}></textarea><br>
1101
+ <input id="mark:submit" type="submit" {{*value="Send comment"*}}>
1102
+ </form>
1103
+
1104
+ plogic*:
1105
+ eruby: |
1106
+ form {
1107
+ stag: start_form_tag :action=>'{{*$(action)*}}';
1108
+ }
1109
+ #comment_username {
1110
+ elem: text_field 'comment', 'username', :size=>{{*$(size)*}};
1111
+ }
1112
+ #comment_text {
1113
+ elem: text_area 'comment', 'text', :rows=>{{*$(rows)*}}, :cols=>{{*$(cols)*}};
1114
+ }
1115
+ #submit {
1116
+ elem: submit_tag '{{*$(value)*}}';
1117
+ }
1118
+
1119
+ php: |
1120
+ form {
1121
+ stag: form_tag('comment/{{*$(action)*}}');
1122
+ }
1123
+ #comment_username {
1124
+ elem: text_field('comment', 'username', array('size'=>{{*$(size)*}}));
1125
+ }
1126
+ #comment_text {
1127
+ elem: text_area('comment', 'text', array('rows'=>{{*$(rows)*}}, 'cols'=>{{*$(cols)*}}));
1128
+ }
1129
+ #submit {
1130
+ elem: submit_tag('{{*$(value)*}}');
1131
+ }
1132
+
1133
+ jstl: |
1134
+ form {
1135
+ logic: {
1136
+ <form:form action="{{*$(action)*}}.do">
1137
+ _cont
1138
+ </form:form>
1139
+ }
1140
+ }
1141
+ #comment_username {
1142
+ logic: {
1143
+ <form:textfield name="username" size="{{*$(size)*}}"/>
1144
+ }
1145
+ }
1146
+ #comment_text {
1147
+ logic: {
1148
+ <form:textarea name="text", rows="{{*$(rows)*}}" cols="{{*$(cols)*}}"/>
1149
+ }
1150
+ }
1151
+ #submit {
1152
+ logic: {
1153
+ <form:submit value="{{*$(value)*}}"/>
1154
+ }
1155
+ }
1156
+
1157
+ eperl: |
1158
+ form {
1159
+ stag: &form_tag({'action'=>'{{*$(action)*}}'});
1160
+ }
1161
+ #comment_username {
1162
+ elem: &text_field('comment', 'username', {'size'=>{{*$(size)*}}});
1163
+ }
1164
+ #comment_text {
1165
+ elem: &text_area('comment', 'text', {'rows'=>{{*$(rows)*}}, 'cols'=>{{*$(cols)*}}});
1166
+ }
1167
+ #submit {
1168
+ elem: &submit_tag('{{*$(value)*}}');
1169
+ }
1170
+
1171
+ expected*:
1172
+
1173
+ eruby: |
1174
+ <%= start_form_tag :action=>'{{*create*}}' %>
1175
+ Username: <%= text_field 'comment', 'username', :size=>{{*30*}} %><br>
1176
+ Comment: <%= text_area 'comment', 'text', :rows=>{{*3*}}, :cols=>{{*50*}} %><br>
1177
+ <%= submit_tag '{{*Send comment*}}' %>
1178
+ </form>
1179
+
1180
+ php: |
1181
+ <?php echo form_tag('comment/{{*create*}}'); ?>
1182
+ Username: <?php echo text_field('comment', 'username', array('size'=>{{*30*}})); ?><br>
1183
+ Comment: <?php echo text_area('comment', 'text', array('rows'=>{{*3*}}, 'cols'=>{{*50*}})); ?><br>
1184
+ <?php echo submit_tag('{{*Send comment*}}'); ?>
1185
+ </form>
1186
+
1187
+ eperl: |
1188
+ <?= &form_tag({'action'=>'{{*create*}}'}) !>
1189
+ Username: <?= &text_field('comment', 'username', {'size'=>{{*30*}}}) !><br>
1190
+ Comment: <?= &text_area('comment', 'text', {'rows'=>{{*3*}}, 'cols'=>{{*50*}}}) !><br>
1191
+ <?= &submit_tag('{{*Send comment*}}') !>
1192
+ </form>
1193
+
1194
+ jstl: |
1195
+ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
1196
+ <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
1197
+ <form:form action="{{*create*}}.do">
1198
+ Username: <form:textfield name="username" size="{{*30*}}"/>
1199
+ <br>
1200
+ Comment: <form:textarea name="text", rows="{{*3*}}" cols="{{*50*}}"/>
1201
+ <br>
1202
+ <form:submit value="{{*Send comment*}}"/>
1203
+ </form:form>
1204
+
1205
+
1206
+ ###
1207
+ - name: attrvar2
1208
+ hide: yes
1209
+ title: Attribute Variable2
1210
+ pdata: |
1211
+ <h1 class="section">...title...</h1>
1212
+
1213
+ plogic*:
1214
+ eruby: |
1215
+ h1 {
1216
+ attrs: 'title' escape('$(class)');
1217
+ value: 'class:$(class)';
1218
+ append: flag ? ' klass="$(class)"' : '';
1219
+ }
1220
+
1221
+ php: |
1222
+ h1 {
1223
+ attrs: 'title' escape('$(class)');
1224
+ value: 'class:$(class)';
1225
+ append: flag ? ' klass="$(class)"' : '';
1226
+ }
1227
+
1228
+ jstl: |
1229
+ h1 {
1230
+ attrs: 'title' escape('$(class)');
1231
+ value: 'class:$(class)';
1232
+ append: flag ? ' klass="$(class)"' : '';
1233
+ }
1234
+
1235
+ eperl: |
1236
+ h1 {
1237
+ attrs: 'title' escape('$(class)');
1238
+ value: 'class:$(class)';
1239
+ append: flag ? ' klass="$(class)"' : '';
1240
+ }
1241
+
1242
+ expected*:
1243
+
1244
+ eruby: |
1245
+ <h1 class="section" title="<%= escape('section') %>"<%= flag ? ' klass="section"' : '' %>><%= 'class:section' %></h1>
1246
+
1247
+ php: |
1248
+ <h1 class="section" title="<?php echo escape('section'); ?>"<?php echo flag ? ' klass="section"' : ''; ?>><?php echo 'class:section'; ?></h1>
1249
+
1250
+ eperl: |
1251
+ <h1 class="section" title="<?= escape('section') !>"<?= flag ? ' klass="section"' : '' !>><?= 'class:section' !></h1>
1252
+
1253
+ jstl: |
1254
+ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
1255
+ <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
1256
+ <h1 class="section" title="${escape('section')}"${flag ? ' klass="section"' : ''}>class:section</h1>
1257
+ # <h1 class="section" title="${escape('section')}"${flag ? ' klass="section"' : ''}>${'class:section'}</h1>
1258
+
1259
+