kwartz 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +444 -0
- data/README.txt +4 -1
- data/bin/kwartz +2 -2
- data/doc-api/classes/Kwartz.html +16 -7
- data/doc-api/classes/Kwartz/Assertion.html +6 -6
- data/doc-api/classes/Kwartz/AssertionError.html +6 -6
- data/doc-api/classes/Kwartz/AttrInfo.html +71 -61
- data/doc-api/classes/Kwartz/BaseError.html +12 -12
- data/doc-api/classes/Kwartz/BaseTranslator.html +104 -74
- data/doc-api/classes/Kwartz/CharacterType.html +24 -24
- data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
- data/doc-api/classes/Kwartz/CommandOptions.html +50 -50
- data/doc-api/classes/Kwartz/Config.html +5 -0
- data/doc-api/classes/Kwartz/ConvertError.html +12 -12
- data/doc-api/classes/Kwartz/Converter.html +31 -33
- data/doc-api/classes/Kwartz/CssStyleParser.html +207 -168
- data/doc-api/classes/Kwartz/Defun.html +32 -31
- data/doc-api/classes/Kwartz/{HandlerArgument.html → Directive.html} +27 -53
- data/doc-api/classes/Kwartz/ElementInfo.html +68 -53
- data/doc-api/classes/Kwartz/EperlExpressionParser.html +185 -0
- data/doc-api/classes/Kwartz/EperlHandler.html +65 -58
- data/doc-api/classes/Kwartz/EperlTranslator.html +14 -7
- data/doc-api/classes/Kwartz/ErubisTranslator.html +14 -7
- data/doc-api/classes/Kwartz/ErubyTranslator.html +14 -7
- data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
- data/doc-api/classes/Kwartz/Expander.html +358 -0
- data/doc-api/classes/Kwartz/Handler.html +287 -157
- data/doc-api/classes/Kwartz/{StatementHelper.html → HandlerHelper.html} +307 -112
- data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +23 -23
- data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +96 -96
- data/doc-api/classes/Kwartz/JstlExpressionParser.html +181 -0
- data/doc-api/classes/Kwartz/JstlHandler.html +134 -126
- data/doc-api/classes/Kwartz/JstlTranslator.html +21 -14
- data/doc-api/classes/Kwartz/KwartzError.html +6 -6
- data/doc-api/classes/Kwartz/Main.html +4 -4
- data/doc-api/classes/Kwartz/NativeExpression.html +19 -19
- data/doc-api/classes/Kwartz/NativeStatement.html +24 -24
- data/doc-api/classes/Kwartz/Node.html +7 -7
- data/doc-api/classes/Kwartz/PIErubisTranslator.html +21 -14
- data/doc-api/classes/Kwartz/ParseError.html +6 -6
- data/doc-api/classes/Kwartz/PerlExpressionParser.html +185 -0
- data/doc-api/classes/Kwartz/PerlHandler.html +353 -0
- data/doc-api/classes/Kwartz/PerlTranslator.html +226 -0
- data/doc-api/classes/Kwartz/PhpExpressionParser.html +185 -0
- data/doc-api/classes/Kwartz/PhpHandler.html +63 -56
- data/doc-api/classes/Kwartz/PhpTranslator.html +21 -14
- data/doc-api/classes/Kwartz/PresentationLogicParser.html +126 -123
- data/doc-api/classes/Kwartz/PrintStatement.html +18 -18
- data/doc-api/classes/Kwartz/RailsHandler.html +84 -85
- data/doc-api/classes/Kwartz/RailsTranslator.html +13 -6
- data/doc-api/classes/Kwartz/RubyExpressionParser.html +180 -0
- data/doc-api/classes/Kwartz/RubyHandler.html +73 -69
- data/doc-api/classes/Kwartz/RubyStyleParser.html +86 -86
- data/doc-api/classes/Kwartz/RubyTranslator.html +28 -21
- data/doc-api/classes/Kwartz/Ruleset.html +622 -1
- data/doc-api/classes/Kwartz/StrutsTranslator.html +14 -14
- data/doc-api/classes/Kwartz/TagInfo.html +52 -27
- data/doc-api/classes/Kwartz/TextConverter.html +75 -37
- data/doc-api/classes/Kwartz/Translator.html +54 -53
- data/doc-api/classes/Kwartz/Util.html +25 -25
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +7 -2
- data/doc-api/files/kwartz/assert_rb.html +2 -2
- data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/erubis_rb.html +2 -2
- data/doc-api/files/kwartz/binding/eruby_rb.html +2 -2
- data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/perl_rb.html +115 -0
- data/doc-api/files/kwartz/binding/php_rb.html +2 -2
- data/doc-api/files/kwartz/binding/pierubis_rb.html +2 -2
- data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
- data/doc-api/files/kwartz/binding/ruby_rb.html +2 -2
- data/doc-api/files/kwartz/binding/struts_rb.html +2 -2
- data/doc-api/files/kwartz/config_rb.html +2 -2
- data/doc-api/files/kwartz/converter_rb.html +2 -2
- data/doc-api/files/kwartz/defun_rb.html +2 -2
- data/doc-api/files/kwartz/error_rb.html +2 -2
- data/doc-api/files/kwartz/helper/rails_rb.html +2 -2
- data/doc-api/files/kwartz/main_rb.html +3 -2
- data/doc-api/files/kwartz/node_rb.html +2 -2
- data/doc-api/files/kwartz/parser_rb.html +2 -2
- data/doc-api/files/kwartz/translator_rb.html +2 -2
- data/doc-api/files/kwartz/util/assert-text-equal_rb.html +2 -2
- data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwartz/util_rb.html +2 -2
- data/doc-api/files/kwartz_rb.html +2 -2
- data/doc-api/fr_class_index.html +10 -5
- data/doc-api/fr_file_index.html +1 -0
- data/doc-api/fr_method_index.html +268 -239
- data/doc/docstyle.css +9 -3
- data/doc/img/fig05.png +0 -0
- data/doc/introduction-to-kwartz.html +3040 -0
- data/doc/pattern-catalog.html +5 -3
- data/doc/reference.html +680 -26
- data/doc/users-guide.html +222 -67
- data/kwartz.gemspec +4 -4
- data/lib/kwartz.rb +3 -3
- data/lib/kwartz/assert.rb +2 -2
- data/lib/kwartz/binding/eperl.rb +71 -31
- data/lib/kwartz/binding/erubis.rb +3 -2
- data/lib/kwartz/binding/eruby.rb +3 -2
- data/lib/kwartz/binding/jstl.rb +66 -29
- data/lib/kwartz/binding/perl.rb +230 -0
- data/lib/kwartz/binding/php.rb +69 -29
- data/lib/kwartz/binding/pierubis.rb +3 -2
- data/lib/kwartz/binding/rails.rb +18 -18
- data/lib/kwartz/binding/ruby.rb +74 -42
- data/lib/kwartz/binding/struts.rb +22 -21
- data/lib/kwartz/config.rb +4 -4
- data/lib/kwartz/converter.rb +465 -345
- data/lib/kwartz/defun.rb +2 -2
- data/lib/kwartz/error.rb +2 -2
- data/lib/kwartz/helper/rails.rb +2 -2
- data/lib/kwartz/main.rb +5 -4
- data/lib/kwartz/node.rb +92 -144
- data/lib/kwartz/parser.rb +112 -103
- data/lib/kwartz/translator.rb +14 -6
- data/lib/kwartz/util.rb +2 -2
- data/lib/kwartz/util/assert-text-equal.rb +2 -2
- data/lib/kwartz/util/testcase-helper.rb +1 -1
- data/test/test-compile.rb +2 -2
- data/test/test-compile.yaml +81 -0
- data/test/test-converter.rb +4 -8
- data/test/test-converter.yaml +152 -3
- data/test/test-directives.rb +2 -2
- data/test/test-directives.yaml +222 -0
- data/test/test-main.rb +6 -4
- data/test/test-main.yaml +66 -1
- data/test/test-parser.rb +12 -3
- data/test/test-parser.yaml +64 -51
- data/test/test-rails.rb +2 -2
- data/test/test-ruleset.rb +2 -2
- data/test/test-ruleset.yaml +465 -4
- data/test/test.log +6 -0
- data/test/test.rb +2 -2
- metadata +116 -106
- data/ChangeLog +0 -156
- data/doc-api/classes/Kwartz/DocumentRuleset.html +0 -369
- data/doc-api/classes/Kwartz/ElementExpander.html +0 -325
- data/doc-api/classes/Kwartz/ElementRuleset.html +0 -612
data/doc/users-guide.html
CHANGED
@@ -13,9 +13,11 @@
|
|
13
13
|
<div class="mainbody">
|
14
14
|
|
15
15
|
<div align="left"><h1>Kwartz-Ruby Users' Guide</h1></div>
|
16
|
-
<
|
17
|
-
$
|
18
|
-
|
16
|
+
<div align="left">
|
17
|
+
release: $Release: 3.2.0 $<br>
|
18
|
+
last update: $Date$<br>
|
19
|
+
</div>
|
20
|
+
|
19
21
|
<a name="preface"></a>
|
20
22
|
<h2 class="section1">Preface</h2>
|
21
23
|
<p>This is the users' guide of Kwartz-ruby.
|
@@ -44,7 +46,7 @@ Kwartz-ruby is an implementation of Kwartz in Ruby.
|
|
44
46
|
</li>
|
45
47
|
<li><a href="#features">Features Overview</a>
|
46
48
|
</li>
|
47
|
-
<li><a href="#example1">
|
49
|
+
<li><a href="#example1">Quick Example</a>
|
48
50
|
</li>
|
49
51
|
<li><a href="#example2">Complex Example</a>
|
50
52
|
</li>
|
@@ -54,12 +56,18 @@ Kwartz-ruby is an implementation of Kwartz in Ruby.
|
|
54
56
|
</li>
|
55
57
|
<li><a href="#detail">Features Detail</a>
|
56
58
|
<ul>
|
59
|
+
<li><a href="#selector">Selector</a>
|
60
|
+
</li>
|
57
61
|
<li><a href="#ruleset">RuleSet and Properties</a>
|
58
62
|
</li>
|
59
63
|
<li><a href="#directives">Directives</a>
|
60
64
|
</li>
|
61
65
|
<li><a href="#embed_expr">Embed Expression in Presentation Data</a>
|
62
66
|
</li>
|
67
|
+
<li><a href="#lang-independent-expr">Language-Independent Expression</a>
|
68
|
+
</li>
|
69
|
+
<li><a href="#attr-variable">Attribute Variable</a>
|
70
|
+
</li>
|
63
71
|
<li><a href="#escape">Escape</a>
|
64
72
|
</li>
|
65
73
|
<li><a href="#langs">Multi-language</a>
|
@@ -141,13 +149,10 @@ If you are familiar with CSS, you'll be also familiar with Kwartz.
|
|
141
149
|
</li>
|
142
150
|
</ul>
|
143
151
|
<div style="text-align: center">
|
144
|
-
<span>Figure1.
|
152
|
+
<span>Figure1. Components in Presentation Layer.</span><br />
|
145
153
|
<img src="img/fig04.png" alt="relation of HTML, CSS, JavaScript, and Kwartz" />
|
146
154
|
</div>
|
147
|
-
<p>
|
148
|
-
</p>
|
149
|
-
<p>In the following, the word 'Kwartz' means the specification of the template system
|
150
|
-
and the word 'Kwartz-ruby' means the implementation of it in Ruby language.
|
155
|
+
<p>If you are interested in concept of Kwartz, see <a href="">this presentation</a>.
|
151
156
|
</p>
|
152
157
|
<div class="footnote">
|
153
158
|
<dl compact>
|
@@ -229,58 +234,31 @@ Auto-escape and Partial-escape</dt>
|
|
229
234
|
|
230
235
|
|
231
236
|
<a name="example1"></a>
|
232
|
-
<h3 class="section2">
|
233
|
-
<p>
|
234
|
-
They may be described in separate files.
|
235
|
-
</p>
|
236
|
-
<p>This is an example of a presentation data file.
|
237
|
-
</p>
|
238
|
-
<ul type="disc">
|
239
|
-
<li>'<strong><code>id="list1"</code></strong>' means "I'll operate this element in presentation logic" (called 'marking' in Kwartz).
|
240
|
-
</li>
|
241
|
-
<li>'<strong><code>id="mark:item1"</code></strong>' is also an marking.
|
242
|
-
Difference between <code>id="mark:item1"</code> and <code>id="item1"</code> is that id attribute in the former format is removed automatically and the latter format is leaved.
|
243
|
-
</li>
|
244
|
-
</ul>
|
245
|
-
<p>Presentation data file(example1.html):
|
237
|
+
<h3 class="section2">Quick Example</h3>
|
238
|
+
<p>Here is an example of presentation data file (= HTML template).
|
246
239
|
</p>
|
247
|
-
<
|
240
|
+
<div class="program_caption">
|
241
|
+
example1.html</div>
|
248
242
|
<pre class="program"><table>
|
249
|
-
<tr <strong>id="list1"</strong>>
|
243
|
+
<tr <strong>id="mark:list1"</strong>>
|
250
244
|
<td <strong>id="mark:item1"</strong>>foo</td>
|
251
245
|
</tr>
|
252
246
|
</table>
|
253
247
|
</pre>
|
254
|
-
<p>
|
255
|
-
In presentation logic, you can operate on elements which are marked in presentation data.
|
248
|
+
<p>Points:
|
256
249
|
</p>
|
257
250
|
<ul type="disc">
|
258
|
-
<li>
|
259
|
-
<ul type="circle">
|
260
|
-
<li>'<strong><code>logic: { ... }</code></strong>' represents presentation logic of the element.
|
261
|
-
</li>
|
262
|
-
<li>'<strong><code>_stag</code></strong>' represents a start tag (= '<tr>').
|
263
|
-
</li>
|
264
|
-
<li>'<strong><code>_cont</code></strong>' represents content(= '<td id="mark:item1">foo</td>').
|
265
|
-
</li>
|
266
|
-
<li>'<strong><code>_etag</code></strong>' represents an end tag(= '</tr>').
|
267
|
-
</li>
|
268
|
-
<li>'<strong><code>for <em>var</em> in <em>list</em> ...</code></strong>' is a Ruby code to loop.
|
269
|
-
In this case, the element(= start-tag + content + end-tag) is looped.
|
270
|
-
</li>
|
271
|
-
</ul>
|
251
|
+
<li>Mark elements by <code>id="mark:xxx"</code> or <code>id="xxx"</code>. The former will be remove at compile stage but the latter will be remained.
|
272
252
|
</li>
|
273
|
-
<li>
|
274
|
-
<ul type="circle">
|
275
|
-
<li>'<strong><code>value: <em>expression</em>;</code></strong>' represents that the content of the element is replaced by value of <code><em>expression</em></code>, which is value of a variable <code>member</code> in this case.
|
276
|
-
</li>
|
277
|
-
</ul>
|
253
|
+
<li>No presentation logics in HTML file.
|
278
254
|
</li>
|
279
255
|
</ul>
|
256
|
+
<p>Here is an example of presentation logic file.
|
257
|
+
</p>
|
280
258
|
<a name="example1.plogic"></a>
|
281
259
|
<div class="program_caption">
|
282
|
-
|
283
|
-
<pre class="program">/* The element which is marked by 'id="list1"' */
|
260
|
+
example1.plogic</div>
|
261
|
+
<pre class="program">/* The element which is marked by 'id="mark:list1"' */
|
284
262
|
<strong>#list1</strong> {
|
285
263
|
logic: {
|
286
264
|
for member in @members
|
@@ -297,28 +275,41 @@ Presentation logic file(example1.plogic):</div>
|
|
297
275
|
value: member;
|
298
276
|
}
|
299
277
|
</pre>
|
300
|
-
<p>
|
278
|
+
<p>Points:
|
301
279
|
</p>
|
302
|
-
<
|
280
|
+
<ul type="disc">
|
281
|
+
<li>Presentation logic is separated from HTML file.
|
282
|
+
</li>
|
283
|
+
<li>Format is very similar to CSS with which you are familiar.
|
284
|
+
</li>
|
285
|
+
<li>Don't forget the semicolon at the end of line!
|
286
|
+
</li>
|
287
|
+
</ul>
|
288
|
+
<p>You must compile presentation data and logic files.
|
303
289
|
</p>
|
304
290
|
<div class="terminal_caption">
|
305
|
-
|
306
|
-
<pre class="terminal">$ kwartz -p example1.plogic example1.html > example1.rhtml
|
291
|
+
Compile</div>
|
292
|
+
<pre class="terminal">$ kwartz -l ruby -p example1.plogic example1.html > example1.rhtml
|
307
293
|
</pre>
|
308
|
-
<p>The following is the compiled output script.
|
309
|
-
Notice that <code>id="mark:item1"</code> is removed automatically while <code>id="list1"</code> is leaved.
|
310
|
-
</p>
|
311
294
|
<a name="example1.expected"></a>
|
312
295
|
<div class="program_caption">
|
313
|
-
|
296
|
+
Generated script (example1.rhtml)</div>
|
314
297
|
<pre class="program"><table>
|
315
|
-
|
316
|
-
<tr
|
317
|
-
<td>
|
298
|
+
<strong><% for member in @members %></strong>
|
299
|
+
<tr>
|
300
|
+
<td><strong><%= member %></strong></td>
|
318
301
|
</tr>
|
319
|
-
|
302
|
+
<strong><% end %></strong>
|
320
303
|
</table>
|
321
304
|
</pre>
|
305
|
+
<p>Points:
|
306
|
+
</p>
|
307
|
+
<ul type="disc">
|
308
|
+
<li>Kwartz compile presentation data and logic files into eRuby, PHP, JSP, Velocity, ....
|
309
|
+
</li>
|
310
|
+
<li>This is why Kwartz is so fast and can support multiple programming languages.
|
311
|
+
</li>
|
312
|
+
</ul>
|
322
313
|
<br>
|
323
314
|
|
324
315
|
|
@@ -491,7 +482,7 @@ See <a href="p-pattern.html">Presentation Pattern Catalog</a> for details.
|
|
491
482
|
</li>
|
492
483
|
</ul>
|
493
484
|
<ul type="disc">
|
494
|
-
<li>Delete
|
485
|
+
<li>Delete element. This is useful for delete dummy data.
|
495
486
|
<pre class="program">#list {
|
496
487
|
logic: {
|
497
488
|
}
|
@@ -551,6 +542,33 @@ This way, you don't need to change presentation logic files even if the tag/attr
|
|
551
542
|
|
552
543
|
<a name="detail"></a>
|
553
544
|
<h2 class="section1">Features Detail</h2>
|
545
|
+
<a name="selector"></a>
|
546
|
+
<h3 class="section2">Selector</h3>
|
547
|
+
<p>(Experimental) Kwartz now supports class selector, tag selector, and multi selector.
|
548
|
+
</p>
|
549
|
+
<pre class="program">/* tag selector */
|
550
|
+
<strong>h1</strong> {
|
551
|
+
Value: title;
|
552
|
+
}
|
553
|
+
/* class selector */
|
554
|
+
<strong>.list</strong> {
|
555
|
+
attrs: 'bgcolor' color;
|
556
|
+
}
|
557
|
+
/* multi selector */
|
558
|
+
#foo<strong>,</strong> #bar<strong>,</strong> .baz {
|
559
|
+
value: item;
|
560
|
+
}
|
561
|
+
</pre>
|
562
|
+
<p>Compound selector is NOT supported.
|
563
|
+
</p>
|
564
|
+
<pre class="program">/* compound selector is not supported */
|
565
|
+
<strong>#foo .baz</strong> { // PARSE ERROR
|
566
|
+
value: item;
|
567
|
+
}
|
568
|
+
</pre>
|
569
|
+
<br>
|
570
|
+
|
571
|
+
|
554
572
|
<a name="ruleset"></a>
|
555
573
|
<h3 class="section2">RuleSet and Properties</h3>
|
556
574
|
<p>Format of presentation logic in Kwartz is similar to CSS (Cascading Style Sheet).
|
@@ -584,14 +602,14 @@ etag: <em>expr</em>; </b></dt>
|
|
584
602
|
<dt class="dt3"><b>
|
585
603
|
elem: <em>expr</em>; </b></dt>
|
586
604
|
<dd class="dd3">
|
587
|
-
Replace
|
605
|
+
Replace element by expression value.
|
588
606
|
</dd>
|
589
607
|
</dl>
|
590
608
|
<dl class="dl3">
|
591
609
|
<dt class="dt3"><b>
|
592
610
|
cont: <em>expr</em>; </b></dt>
|
593
611
|
<dd class="dd3">
|
594
|
-
Replace content of element by
|
612
|
+
Replace content of element by expression value.
|
595
613
|
</dd>
|
596
614
|
</dl>
|
597
615
|
<dl class="dl3">
|
@@ -645,6 +663,20 @@ logic: { ... } </b></dt>
|
|
645
663
|
Logic of the element.
|
646
664
|
</dd>
|
647
665
|
</dl>
|
666
|
+
<dl class="dl3">
|
667
|
+
<dt class="dt3"><b>
|
668
|
+
before: { ... } </b></dt>
|
669
|
+
<dd class="dd3">
|
670
|
+
Logics executed before 'logic:' part.
|
671
|
+
</dd>
|
672
|
+
</dl>
|
673
|
+
<dl class="dl3">
|
674
|
+
<dt class="dt3"><b>
|
675
|
+
after: { ... } </b></dt>
|
676
|
+
<dd class="dd3">
|
677
|
+
Logics executed after 'logic:' part.
|
678
|
+
</dd>
|
679
|
+
</dl>
|
648
680
|
<p>'stag:' and 'elem:' are useful especially for Ruby on Rails.
|
649
681
|
The following is an examle to use Kwartz in Ruby on Rails.
|
650
682
|
</p>
|
@@ -814,7 +846,7 @@ presentation data (embed1_ruby.html)</div>
|
|
814
846
|
<a name="embed1_ruby.expected"></a>
|
815
847
|
<div class="terminal_caption">
|
816
848
|
compile</div>
|
817
|
-
<pre class="terminal">$ kwartz -l
|
849
|
+
<pre class="terminal">$ kwartz -l ruby embed1_ruby.html
|
818
850
|
_buf = ""; _buf << "<p class=\"<strong>#{klass}</strong>\">Hello <strong>#{ERB::Util.h user}</strong></p>
|
819
851
|
<p class=\""; _buf << <strong>(klass).to_s</strong>; _buf << "\">Hello "; _buf << <strong>ERB::Util.h(user)</strong>; _buf << "</p>\n";
|
820
852
|
; _buf
|
@@ -835,6 +867,121 @@ compile</div>
|
|
835
867
|
<br>
|
836
868
|
|
837
869
|
|
870
|
+
<a name="lang-independent-expr"></a>
|
871
|
+
<h3 class="section2">Language-Independent Expression</h3>
|
872
|
+
<p>Basically, embedded expression should be target language. For example if you are Rails developer then you should embed Ruby expression into html file, or if you are PHP programmer you must embed PHP expression. This will prevent you to share html template files (or reuse) between different projects (such as Rails project and PHP project).
|
873
|
+
</p>
|
874
|
+
<p>Now Kwartz supports language-independent expression. If expression matches the following pattern then it is recognized as language-independent expression, else as language-depend expression.
|
875
|
+
</p>
|
876
|
+
<ul type="disc">
|
877
|
+
<li><code>variable</code>
|
878
|
+
</li>
|
879
|
+
<li><code>object.property</code>
|
880
|
+
</li>
|
881
|
+
<li><code>hash['key']</code>, <code>hash["key"]</code>, <code>hash[:key]</code>
|
882
|
+
</li>
|
883
|
+
<li><code>array[123]</code>, <code>array[index]</code>
|
884
|
+
</li>
|
885
|
+
</ul>
|
886
|
+
<p>Language-independet expression is converted into target language automatically. For example, <code>user.name</code> will be converted into <code>$user->name</code> in PHP.
|
887
|
+
</p>
|
888
|
+
<div class="program_caption">
|
889
|
+
Example (expr.html)</div>
|
890
|
+
<pre class="program"><p id="value:user">foo</p>
|
891
|
+
<p id="value:user.name">foo</p>
|
892
|
+
<p id="value:user['name']">foo</p>
|
893
|
+
<p id="value:user[:name]">foo</p>
|
894
|
+
<p id="value:user[0]">foo</p>
|
895
|
+
<p id="value:user[i]">foo</p>
|
896
|
+
<div>
|
897
|
+
@!{user}@
|
898
|
+
@!{user.name}@
|
899
|
+
@!{user['name']}@
|
900
|
+
@!{user[:name]}@
|
901
|
+
@!{user[0]}@
|
902
|
+
@!{user[i]}@
|
903
|
+
@!{$user->name}@
|
904
|
+
</div>
|
905
|
+
</pre>
|
906
|
+
<div class="terminal_caption">
|
907
|
+
Compile:</div>
|
908
|
+
<pre class="terminal">$ kwarz -l eruby expr.html
|
909
|
+
<p><%= <strong>user</strong> %></p>
|
910
|
+
<p><%= <strong>user.name</strong> %></p>
|
911
|
+
<p><%= <strong>user['name']</strong> %></p>
|
912
|
+
<p><%= <strong>user[:name]</strong> %></p>
|
913
|
+
<p><%= <strong>user[0]</strong> %></p>
|
914
|
+
<p><%= <strong>user[i]</strong> %></p>
|
915
|
+
<div>
|
916
|
+
<%= <strong>user</strong> %>
|
917
|
+
<%= <strong>user.name</strong> %>
|
918
|
+
<%= <strong>user['name']</strong> %>
|
919
|
+
<%= <strong>user[:name]</strong> %>
|
920
|
+
<%= <strong>user[0]</strong> %>
|
921
|
+
<%= <strong>user[i]</strong> %>
|
922
|
+
<%= <strong>$user->name</strong> %>
|
923
|
+
</div>
|
924
|
+
$ kwartz -l php expr.html
|
925
|
+
<p><?php echo <strong>$user</strong>; ?></p>
|
926
|
+
<p><?php echo <strong>$user->name</strong>; ?></p>
|
927
|
+
<p><?php echo <strong>$user['name']</strong>; ?></p>
|
928
|
+
<p><?php echo <strong>$user['name']</strong>; ?></p>
|
929
|
+
<p><?php echo <strong>$user[0]</strong>; ?></p>
|
930
|
+
<p><?php echo <strong>$user[$i]</strong>; ?></p>
|
931
|
+
<div>
|
932
|
+
<?php echo <strong>$user</strong>; ?>
|
933
|
+
<?php echo <strong>$user->name</strong>; ?>
|
934
|
+
<?php echo <strong>$user['name']</strong>; ?>
|
935
|
+
<?php echo <strong>$user['name']</strong>; ?>
|
936
|
+
<?php echo <strong>$user[0]</strong>; ?>
|
937
|
+
<?php echo <strong>$user[$i]</strong>; ?>
|
938
|
+
<?php echo <strong>$user->name</strong>; ?>
|
939
|
+
</div>
|
940
|
+
</pre>
|
941
|
+
<p> This feature is limited for basic expression but will help you to share or reuse html templates between projects.
|
942
|
+
</p>
|
943
|
+
<br>
|
944
|
+
|
945
|
+
|
946
|
+
<a name="attr-variable"></a>
|
947
|
+
<h3 class="section2">Attribute Variable</h3>
|
948
|
+
<p>Attribute variable represents attribute value of element.
|
949
|
+
</p>
|
950
|
+
<div class="program_caption">
|
951
|
+
presentation data (form.html)</div>
|
952
|
+
<pre class="program"><form <strong>action="create"</strong>>
|
953
|
+
Username: <input type="text" id="comment_username" <strong>size="20"</strong>><br>
|
954
|
+
Comment: <textarea id="comment_body" <strong>cols="40"</strong> <strong>rows="3"</strong>></textarea><br>
|
955
|
+
<input type="submit" id="mark:comment_submit" <strong>value="Send comment"</strong>>
|
956
|
+
</form>
|
957
|
+
</pre>
|
958
|
+
<div class="program_caption">
|
959
|
+
form.plogic</div>
|
960
|
+
<pre class="program">form {
|
961
|
+
stag: start_form_tag :action=>'<strong>$(action)</strong>';
|
962
|
+
}
|
963
|
+
#comment_username {
|
964
|
+
elem: text_field 'comment', 'username', :size=><strong>$(size)</strong>;
|
965
|
+
}
|
966
|
+
#comment_body {
|
967
|
+
elem: text_area 'comment', 'body', :rows=><strong>$(rows)</strong>, :cols=><strong>$(cols)</strong>;
|
968
|
+
}
|
969
|
+
#comment_submit {
|
970
|
+
elem: submit_tag '<strong>$(value)</strong>';
|
971
|
+
}
|
972
|
+
</pre>
|
973
|
+
<div class="terminal_caption">
|
974
|
+
compile</div>
|
975
|
+
<pre class="terminal">$ kwartz -p form.plogic form.html
|
976
|
+
<%= start_form_tag :action=>'<strong>create</strong>' %>
|
977
|
+
Username: <%= text_field 'comment', 'username', :size=><strong>20</strong> %><br>
|
978
|
+
Comment: <%= text_area 'comment', 'body', :rows=><strong>3</strong>, :cols=><strong>40</strong> %><br>
|
979
|
+
<%= submit_tag '<strong>Send comment</strong>' %>
|
980
|
+
</form>
|
981
|
+
</pre>
|
982
|
+
<br>
|
983
|
+
|
984
|
+
|
838
985
|
<a name="escape"></a>
|
839
986
|
<h3 class="section2">Escape</h3>
|
840
987
|
<p>Kwartz supports Automatic-escape and Partial-escape/unescape.
|
@@ -1490,7 +1637,7 @@ print statement because they can escape or unescape exression value.
|
|
1490
1637
|
<a name="begin"></a>
|
1491
1638
|
<h3 class="section2">Add Code at Beginning/End of Document</h3>
|
1492
1639
|
<p>'#DOCUMENT' is a special selector which represents the document.
|
1493
|
-
|
1640
|
+
You can use 'before:' and 'after:' to add codes at beginning/end of document<sup>(<a href="#fnref:6" name="fnlink:6">*6</a>)</sup>.
|
1494
1641
|
</p>
|
1495
1642
|
<a name="document-test.html"></a>
|
1496
1643
|
<div class="program_caption">
|
@@ -1503,11 +1650,11 @@ document-test.html</div>
|
|
1503
1650
|
<div class="program_caption">
|
1504
1651
|
document-test.plogic</div>
|
1505
1652
|
<pre class="program"><strong>#DOCUMENT</strong> {
|
1506
|
-
<strong>
|
1653
|
+
<strong>before:</strong> {
|
1507
1654
|
title = cgi['title']
|
1508
1655
|
user = cgi['user']
|
1509
1656
|
}
|
1510
|
-
<strong>
|
1657
|
+
<strong>after:</strong> {
|
1511
1658
|
print "<!--end-->\n"
|
1512
1659
|
}
|
1513
1660
|
}
|
@@ -1523,6 +1670,12 @@ compile</div>
|
|
1523
1670
|
</html>
|
1524
1671
|
<strong><%= "<!--end-->\n" %></strong>
|
1525
1672
|
</pre>
|
1673
|
+
<div class="footnote">
|
1674
|
+
<dl compact>
|
1675
|
+
<dt>(<a name="fnref:6" href="#fnlink:6">*6</a>)</dt>
|
1676
|
+
<dd>'begin:' and 'end:' are also available but obolete. Please use 'before:' and 'after:' instead.</dd>
|
1677
|
+
</dl>
|
1678
|
+
</div>
|
1526
1679
|
<br>
|
1527
1680
|
|
1528
1681
|
|
@@ -1632,6 +1785,8 @@ _erbout
|
|
1632
1785
|
<p>This section shows how to use Kwartz with Ruby on Rails.
|
1633
1786
|
See 'examples/rails1' and 'examples/rails2' for examples.
|
1634
1787
|
</p>
|
1788
|
+
<p><span style="color:#FF0000">NOTICE: THIS IS OBSOLETE INFORMATION.</span>
|
1789
|
+
</p>
|
1635
1790
|
<a name="rails_template"></a>
|
1636
1791
|
<h3 class="section2">Support of Ruby on Rails</h3>
|
1637
1792
|
<p>If you want to use Kwartz with Ruby on Rails, add the following code in your 'app/controllers/application.rb' and restart web server.
|
data/kwartz.gemspec
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
###
|
4
4
|
### RubyGems Specification file for Kwartz-ruby
|
5
5
|
###
|
6
|
-
### $Rev
|
7
|
-
### $Release: 3.
|
6
|
+
### $Rev$
|
7
|
+
### $Release: 3.2.0 $
|
8
8
|
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
9
9
|
###
|
10
10
|
|
@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
|
|
14
14
|
## package information
|
15
15
|
s.name = 'kwartz'
|
16
16
|
s.author = 'Makoto Kuwata'
|
17
|
-
s.version = ("$Release: 3.
|
17
|
+
s.version = ("$Release: 3.2.0 $" =~ /[\.\d]+/) && $&
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
s.homepage = 'http://www.kuwata-lab.com/kwartz'
|
20
20
|
s.summary = "a template system for Ruby, PHP, and Java"
|
@@ -45,7 +45,7 @@ spec = Gem::Specification.new do |s|
|
|
45
45
|
# #"doc/design.css", "doc/design.html",
|
46
46
|
# ]
|
47
47
|
files += Dir.glob('doc-api/**/*')
|
48
|
-
files += %w[README.txt
|
48
|
+
files += %w[README.txt CHANGES LGPL setup.rb kwartz.gemspec]
|
49
49
|
s.files = files
|
50
50
|
s.executables = ["kwartz"]
|
51
51
|
s.bindir = "bin"
|