tenjin 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.txt +54 -0
- data/benchmark/bench.rb +502 -0
- data/benchmark/bench_context.rb +17 -0
- data/benchmark/bench_context.yaml +141 -0
- data/benchmark/templates/_footer.html +4 -0
- data/benchmark/templates/_header.html +52 -0
- data/benchmark/templates/bench_eruby.rhtml +29 -0
- data/benchmark/templates/bench_tenjin.rbhtml +29 -0
- data/bin/rbtenjin +449 -0
- data/doc-api/classes/Tenjin.html +141 -0
- data/doc-api/classes/Tenjin/ArrayBufferTemplate.html +270 -0
- data/doc-api/classes/Tenjin/BaseContext.html +312 -0
- data/doc-api/classes/Tenjin/Context.html +126 -0
- data/doc-api/classes/Tenjin/ContextHelper.html +433 -0
- data/doc-api/classes/Tenjin/Engine.html +616 -0
- data/doc-api/classes/Tenjin/ErubisTemplate.html +166 -0
- data/doc-api/classes/Tenjin/HtmlHelper.html +359 -0
- data/doc-api/classes/Tenjin/Preprocessor.html +242 -0
- data/doc-api/classes/Tenjin/Template.html +916 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/README_txt.html +185 -0
- data/doc-api/files/lib/tenjin_rb.html +136 -0
- data/doc-api/fr_class_index.html +36 -0
- data/doc-api/fr_file_index.html +28 -0
- data/doc-api/fr_method_index.html +89 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/docstyle.css +188 -0
- data/doc/examples.html +312 -0
- data/doc/faq.html +909 -0
- data/doc/users-guide.html +1691 -0
- data/lib/tenjin.rb +959 -0
- data/setup.rb +1331 -0
- data/tenjin.gemspec +58 -0
- data/test/assert-text-equal.rb +45 -0
- data/test/data/examples/form/create.rbhtml +4 -0
- data/test/data/examples/form/form.rbhtml +14 -0
- data/test/data/examples/form/layout.rbhtml +8 -0
- data/test/data/examples/form/main.rb +9 -0
- data/test/data/examples/form/main.result +21 -0
- data/test/data/examples/form/update.rbhtml +4 -0
- data/test/data/examples/preprocessing/helper.rb +16 -0
- data/test/data/examples/preprocessing/main.rb +11 -0
- data/test/data/examples/preprocessing/main.result +17 -0
- data/test/data/examples/preprocessing/select.rbhtml +15 -0
- data/test/data/examples/preprocessing/select_P.result +18 -0
- data/test/data/examples/table/table.rb +9 -0
- data/test/data/examples/table/table.rbhtml +16 -0
- data/test/data/examples/table/table.result +20 -0
- data/test/data/examples/table/table_s.result +18 -0
- data/test/data/faq/ex1.rbhtml +5 -0
- data/test/data/faq/ex10-baselayout.rbhtml +27 -0
- data/test/data/faq/ex10-content.rbhtml +12 -0
- data/test/data/faq/ex10-customlayout.rbhtml +11 -0
- data/test/data/faq/ex10_inherit.result +25 -0
- data/test/data/faq/ex11-bench.rb +28 -0
- data/test/data/faq/ex11-content.rbhtml +9 -0
- data/test/data/faq/ex11-layout1.rbhtml +5 -0
- data/test/data/faq/ex11-layout2.rbhtml +6 -0
- data/test/data/faq/ex11.rb +5 -0
- data/test/data/faq/ex11.rbhtml +8 -0
- data/test/data/faq/ex11.source +11 -0
- data/test/data/faq/ex11_arraybuffer.result +15 -0
- data/test/data/faq/ex1_chksyntax.result +3 -0
- data/test/data/faq/ex2-content.rbhtml +3 -0
- data/test/data/faq/ex2-layout.rbhtml +11 -0
- data/test/data/faq/ex2_removenl.result +19 -0
- data/test/data/faq/ex3.rb +4 -0
- data/test/data/faq/ex3.rbhtml +1 -0
- data/test/data/faq/ex3_escapefunc1.result +2 -0
- data/test/data/faq/ex3_escapefunc2.result +2 -0
- data/test/data/faq/ex5.rbhtml +7 -0
- data/test/data/faq/ex5_template_args.source +9 -0
- data/test/data/faq/ex6-content.rhtml +6 -0
- data/test/data/faq/ex6-layout.rhtml +6 -0
- data/test/data/faq/ex6.rb +10 -0
- data/test/data/faq/ex6_eruby.result +12 -0
- data/test/data/faq/ex7-expr-pattern.rb +34 -0
- data/test/data/faq/ex7-expr-pattern.rbhtml +3 -0
- data/test/data/faq/ex7_expr_pattern.result +4 -0
- data/test/data/faq/ex8-m18n.rb +77 -0
- data/test/data/faq/ex8-m18n.rbhtml +4 -0
- data/test/data/faq/ex8_m18n.result +10 -0
- data/test/data/faq/ex9-baselayout.rbhtml +8 -0
- data/test/data/faq/ex9-content.rbhtml +6 -0
- data/test/data/faq/ex9-mylayout.rbhtml +5 -0
- data/test/data/faq/ex9_changelayout.result +11 -0
- data/test/data/users_guide/content6.rbhtml +3 -0
- data/test/data/users_guide/content7.rbhtml +5 -0
- data/test/data/users_guide/content8.rbhtml +2 -0
- data/test/data/users_guide/contextdata.rb +7 -0
- data/test/data/users_guide/datafile.rb +5 -0
- data/test/data/users_guide/datafile.yaml +10 -0
- data/test/data/users_guide/ex.rbhtml +6 -0
- data/test/data/users_guide/ex.result +7 -0
- data/test/data/users_guide/ex.script +5 -0
- data/test/data/users_guide/ex_script.result +7 -0
- data/test/data/users_guide/ex_source.result +8 -0
- data/test/data/users_guide/example1.rbhtml +12 -0
- data/test/data/users_guide/example1.result +17 -0
- data/test/data/users_guide/example10.rbhtml +4 -0
- data/test/data/users_guide/example10_template_args.result +6 -0
- data/test/data/users_guide/example11.rbhtml +5 -0
- data/test/data/users_guide/example11_template_args_result +2 -0
- data/test/data/users_guide/example12.rbhtml +12 -0
- data/test/data/users_guide/example12_preprocessed.result +10 -0
- data/test/data/users_guide/example12_preprocessed_source.result +10 -0
- data/test/data/users_guide/example13.rbhtml +6 -0
- data/test/data/users_guide/example13_preprocessed.result +2 -0
- data/test/data/users_guide/example13_preprocessed_source.result +2 -0
- data/test/data/users_guide/example14.rb +32 -0
- data/test/data/users_guide/example14.rbhtml +6 -0
- data/test/data/users_guide/example14_tmplclass.result +15 -0
- data/test/data/users_guide/example15.rb +10 -0
- data/test/data/users_guide/example15_escapefunc.result +14 -0
- data/test/data/users_guide/example16.rbhtml +4 -0
- data/test/data/users_guide/example16a.rb +10 -0
- data/test/data/users_guide/example16a.result +4 -0
- data/test/data/users_guide/example16b.rb +13 -0
- data/test/data/users_guide/example16b.result +4 -0
- data/test/data/users_guide/example16c.rb +12 -0
- data/test/data/users_guide/example16c.result +4 -0
- data/test/data/users_guide/example1_S.result +14 -0
- data/test/data/users_guide/example1_SXNC.result +10 -0
- data/test/data/users_guide/example1_source.result +14 -0
- data/test/data/users_guide/example2.rbhtml +3 -0
- data/test/data/users_guide/example2_sb.result2 +9 -0
- data/test/data/users_guide/example3.rbhtml +5 -0
- data/test/data/users_guide/example3_syntaxcheck.result +2 -0
- data/test/data/users_guide/example4.rbhtml +13 -0
- data/test/data/users_guide/example4_datafile_rb.result +13 -0
- data/test/data/users_guide/example4_yaml.result +13 -0
- data/test/data/users_guide/example5.rbhtml +9 -0
- data/test/data/users_guide/example5_datastr_rb.result +9 -0
- data/test/data/users_guide/example5_datastr_yaml.result +9 -0
- data/test/data/users_guide/example6.rbhtml +19 -0
- data/test/data/users_guide/example6_layout.result +29 -0
- data/test/data/users_guide/example6_nested.result +28 -0
- data/test/data/users_guide/example7_layout2.result +13 -0
- data/test/data/users_guide/example8_layout3.result +8 -0
- data/test/data/users_guide/example9.rbhtml +18 -0
- data/test/data/users_guide/example9_capture.result +26 -0
- data/test/data/users_guide/footer.html +5 -0
- data/test/data/users_guide/footer.rbhtml +4 -0
- data/test/data/users_guide/layout6.rbhtml +17 -0
- data/test/data/users_guide/layout7.rbhtml +9 -0
- data/test/data/users_guide/layout8_html.rbhtml +5 -0
- data/test/data/users_guide/layout8_xhtml.rbhtml +6 -0
- data/test/data/users_guide/layout9.rbhtml +25 -0
- data/test/data/users_guide/sidemenu.rbhtml +5 -0
- data/test/data/users_guide/user_app.cgi +39 -0
- data/test/data/users_guide/user_app.result +30 -0
- data/test/data/users_guide/user_create.rbhtml +6 -0
- data/test/data/users_guide/user_edit.rbhtml +7 -0
- data/test/data/users_guide/user_form.rbhtml +10 -0
- data/test/data/users_guide/user_layout.rbhtml +16 -0
- data/test/test_all.rb +23 -0
- data/test/test_engine.rb +526 -0
- data/test/test_engine.yaml +2039 -0
- data/test/test_examples.rb +81 -0
- data/test/test_faq.rb +60 -0
- data/test/test_htmlhelper.rb +78 -0
- data/test/test_main.rb +564 -0
- data/test/test_main.yaml +174 -0
- data/test/test_template.rb +113 -0
- data/test/test_template.yaml +1244 -0
- data/test/test_users_guide.rb +75 -0
- data/test/testcase-helper.rb +166 -0
- metadata +226 -0
data/doc-api/index.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
+
|
6
|
+
<!--
|
7
|
+
|
8
|
+
RDoc Documentation
|
9
|
+
|
10
|
+
-->
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
+
<head>
|
13
|
+
<title>RDoc Documentation</title>
|
14
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
+
</head>
|
16
|
+
<frameset rows="20%, 80%">
|
17
|
+
<frameset cols="25%,35%,45%">
|
18
|
+
<frame src="fr_file_index.html" title="Files" name="Files" />
|
19
|
+
<frame src="fr_class_index.html" name="Classes" />
|
20
|
+
<frame src="fr_method_index.html" name="Methods" />
|
21
|
+
</frameset>
|
22
|
+
<frame src="files/README_txt.html" name="docwin" />
|
23
|
+
</frameset>
|
24
|
+
</html>
|
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
data/doc/docstyle.css
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
body {
|
2
|
+
background-color:#FFFFFF;
|
3
|
+
}
|
4
|
+
|
5
|
+
.mainbody {
|
6
|
+
color:#333333;
|
7
|
+
line-height:150%;
|
8
|
+
margin: 5px 30px 5px 30px;
|
9
|
+
}
|
10
|
+
|
11
|
+
a:link, a:active, a:hover {
|
12
|
+
color:#CC6600;
|
13
|
+
}
|
14
|
+
|
15
|
+
a:visited {
|
16
|
+
color:#DD9900;
|
17
|
+
}
|
18
|
+
|
19
|
+
p {
|
20
|
+
color:#333333;
|
21
|
+
line-height:150%;
|
22
|
+
}
|
23
|
+
|
24
|
+
pre {
|
25
|
+
width: 100%;
|
26
|
+
line-height:130%;
|
27
|
+
white-space:pre;
|
28
|
+
}
|
29
|
+
|
30
|
+
.program {
|
31
|
+
border-style:solid;
|
32
|
+
border-width:1px;
|
33
|
+
border-color:#6699FF;
|
34
|
+
color:#333333;
|
35
|
+
background-color:#DDEEFF;
|
36
|
+
padding:8px 9px 8px 9px;
|
37
|
+
margin:0px;
|
38
|
+
word-break:break-all;
|
39
|
+
}
|
40
|
+
|
41
|
+
.terminal {
|
42
|
+
border-style:solid;
|
43
|
+
border-width:1;
|
44
|
+
border-color:#999999;
|
45
|
+
color:#333333;
|
46
|
+
background-color:#E0E0E0;
|
47
|
+
padding:9px 10px 9px 10px;
|
48
|
+
margin:0px;
|
49
|
+
word-break:break-all;
|
50
|
+
}
|
51
|
+
|
52
|
+
.output {
|
53
|
+
border-style:solid;
|
54
|
+
border-width:1px;
|
55
|
+
border-color:#CCCCCC;
|
56
|
+
color:#333333;
|
57
|
+
background-color:#FFFFFF;
|
58
|
+
padding:8px 9px 8px 9px;
|
59
|
+
margin:0px;
|
60
|
+
word-break:break-all;
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
.program_caption {
|
65
|
+
margin-top: 20px;
|
66
|
+
}
|
67
|
+
|
68
|
+
.terminal_caption {
|
69
|
+
margin-top: 20px;
|
70
|
+
}
|
71
|
+
|
72
|
+
.output_caption {
|
73
|
+
margin-top: 20px;
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
ul,ol,dl {
|
78
|
+
/* margin:0px; */
|
79
|
+
/* padding:0px; */
|
80
|
+
color:#333333;
|
81
|
+
line-height:140%;
|
82
|
+
}
|
83
|
+
|
84
|
+
.dt2, .dt3 {
|
85
|
+
font-weight:bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
.table1 {
|
89
|
+
padding:2px;
|
90
|
+
color:#333333;
|
91
|
+
background-color:#DDDDCC;
|
92
|
+
line-height:130%;
|
93
|
+
/*
|
94
|
+
border-width:1px;
|
95
|
+
border-style:solid;
|
96
|
+
border-color:#FFFFFF;
|
97
|
+
*/
|
98
|
+
margin:5;
|
99
|
+
}
|
100
|
+
|
101
|
+
.th1, .th2 {
|
102
|
+
padding:1px;
|
103
|
+
color:#333333;
|
104
|
+
/* background-color:#DDDDCC; */
|
105
|
+
background-color:#CCCCBB;
|
106
|
+
line-height:130%;
|
107
|
+
}
|
108
|
+
|
109
|
+
.td1, .th2 {
|
110
|
+
padding:1px;
|
111
|
+
color:#333333;
|
112
|
+
background-color:#EEEEDD;
|
113
|
+
line-height:130%;
|
114
|
+
}
|
115
|
+
|
116
|
+
.caption1, .caption2 {
|
117
|
+
/* font-size:x-small; */
|
118
|
+
color:#333333;
|
119
|
+
}
|
120
|
+
|
121
|
+
.table2 {
|
122
|
+
padding:1px;
|
123
|
+
color:#333333;
|
124
|
+
background-color:#DDDDCC;
|
125
|
+
line-height:130%;
|
126
|
+
/*
|
127
|
+
border-width:1px;
|
128
|
+
border-style:solid;
|
129
|
+
border-color:#FFFFFF;
|
130
|
+
*/
|
131
|
+
margin:5;
|
132
|
+
}
|
133
|
+
|
134
|
+
h1, .chapter, .doctitle {
|
135
|
+
color:#333333;
|
136
|
+
font-weight:bold;
|
137
|
+
padding:30px 0px 10px 0px;
|
138
|
+
}
|
139
|
+
|
140
|
+
h2, .section {
|
141
|
+
color:#333333;
|
142
|
+
font-weight:bold;
|
143
|
+
border-style:solid;
|
144
|
+
border-color:#6699FF;
|
145
|
+
border-width:0px 0px 2px 30px;
|
146
|
+
padding:10px 20px 0px 5px;
|
147
|
+
}
|
148
|
+
|
149
|
+
h3, .subsection {
|
150
|
+
color:#333333;
|
151
|
+
font-weight:bold;
|
152
|
+
border-style:solid;
|
153
|
+
border-color:#6699FF;
|
154
|
+
border-width: 0px 0px 0px 15px;
|
155
|
+
padding: 10px 20px 0px 5px;
|
156
|
+
}
|
157
|
+
|
158
|
+
.em {
|
159
|
+
font-weight:bold;
|
160
|
+
}
|
161
|
+
|
162
|
+
.toc {
|
163
|
+
/* font-size:small; */
|
164
|
+
/* line-height:100%; */
|
165
|
+
}
|
166
|
+
|
167
|
+
.footnote {
|
168
|
+
font-size:small;
|
169
|
+
}
|
170
|
+
|
171
|
+
.note {
|
172
|
+
background-color:#FFFFDD;
|
173
|
+
border-style:solid;
|
174
|
+
border-width:0px 1px 0px 1px;
|
175
|
+
border-color:#DDDD66;
|
176
|
+
color:#333300;
|
177
|
+
/* font-size:small; */
|
178
|
+
line-height:120%;
|
179
|
+
padding: 5px 20px 5px 20px;
|
180
|
+
}
|
181
|
+
|
182
|
+
.figure {
|
183
|
+
/*
|
184
|
+
border-width:1px;
|
185
|
+
border-color:#DDDD66;
|
186
|
+
white-space:pre;
|
187
|
+
*/
|
188
|
+
}
|
data/doc/examples.html
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html">
|
5
|
+
<title>rbTenjin Examples</title>
|
6
|
+
<meta name="generator" content="kwaser">
|
7
|
+
<meta http-equiv="Content-Style-Type" content="text/css">
|
8
|
+
<link rel="stylesheet" href="docstyle.css" type="text/css">
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<blockquote>
|
13
|
+
<div class="mainbody">
|
14
|
+
|
15
|
+
<div align="left"><h1>rbTenjin Examples</h1></div>
|
16
|
+
<div align="left">
|
17
|
+
last update: $Date: 2007-08-04 13:23:33 +0900 (Sat, 04 Aug 2007) $<br>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<p>Release: 0.6.0
|
21
|
+
</p>
|
22
|
+
<p>Table of Contents:
|
23
|
+
<ul>
|
24
|
+
<li><a href="#bordered-table">Bordered Table</a>
|
25
|
+
</li>
|
26
|
+
<li><a href="#form">Form</a>
|
27
|
+
</li>
|
28
|
+
<li><a href="#preprocessing">Preprocessing</a>
|
29
|
+
</li>
|
30
|
+
</ul>
|
31
|
+
</p>
|
32
|
+
<a name="bordered-table"></a>
|
33
|
+
<h2 class="section1">Bordered Table</h2>
|
34
|
+
<a name="table/table.rbhtml"></a>
|
35
|
+
<div class="program_caption">
|
36
|
+
Template: 'table.rbhtml'</div>
|
37
|
+
<pre class="program"><html>
|
38
|
+
<body>
|
39
|
+
<h1><strong>${@title}</strong></h1>
|
40
|
+
<table>
|
41
|
+
<strong><?rb i = 0 ?></strong>
|
42
|
+
<strong><?rb for item in @items ?></strong>
|
43
|
+
<strong><?rb i += 1 ?></strong>
|
44
|
+
<strong><?rb color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ?></strong>
|
45
|
+
<tr bgcolor="<strong>#{color}</strong>">
|
46
|
+
<td><strong>#{i}</strong></td>
|
47
|
+
<td><strong>${item}</strong></td>
|
48
|
+
</tr>
|
49
|
+
<strong><?rb end ?></strong>
|
50
|
+
</table>
|
51
|
+
</body>
|
52
|
+
</html>
|
53
|
+
</pre>
|
54
|
+
<a name="table/table_s.result"></a>
|
55
|
+
<div class="terminal_caption">
|
56
|
+
Convert into Ruby script:</div>
|
57
|
+
<pre class="terminal">$ rbtenjin -a convert table.rbhtml
|
58
|
+
_buf = ''; _buf << %Q`<html>
|
59
|
+
<body>
|
60
|
+
<h1><strong>#{escape((@title).to_s)}</strong></h1>
|
61
|
+
<table>\n`
|
62
|
+
<strong>i = 0</strong>
|
63
|
+
<strong>for item in @items</strong>
|
64
|
+
<strong>i += 1</strong>
|
65
|
+
<strong>color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'</strong>
|
66
|
+
_buf << %Q` <tr bgcolor="<strong>#{color}</strong>">
|
67
|
+
<td><strong>#{i}</strong></td>
|
68
|
+
<td><strong>#{escape((item).to_s)}</strong></td>
|
69
|
+
</tr>\n`
|
70
|
+
<strong>end</strong>
|
71
|
+
_buf << %Q` </table>
|
72
|
+
</body>
|
73
|
+
</html>\n`
|
74
|
+
_buf.to_s
|
75
|
+
</pre>
|
76
|
+
<a name="table/table.rb"></a>
|
77
|
+
<div class="program_caption">
|
78
|
+
Main program: 'table.rb'</div>
|
79
|
+
<pre class="program">## create Engine object
|
80
|
+
require 'tenjin'
|
81
|
+
<strong>engine = Tenjin::Engine.new()</strong>
|
82
|
+
|
83
|
+
## render template with context data
|
84
|
+
context = { :title => 'Bordered Table Example',
|
85
|
+
:items => [ '<AAA>', 'B&B', '"CCC"' ] }
|
86
|
+
<strong>output = engine.render('table.rbhtml', context)</strong>
|
87
|
+
puts output
|
88
|
+
</pre>
|
89
|
+
<a name="table/table.result"></a>
|
90
|
+
<div class="terminal_caption">
|
91
|
+
Result:</div>
|
92
|
+
<pre class="terminal">$ ruby table.rb
|
93
|
+
<html>
|
94
|
+
<body>
|
95
|
+
<h1>Bordered Table Example</h1>
|
96
|
+
<table>
|
97
|
+
<tr bgcolor="<strong>#CCCCFF</strong>">
|
98
|
+
<td><strong>1</strong></td>
|
99
|
+
<td><strong>&lt;AAA&gt;</strong></td>
|
100
|
+
</tr>
|
101
|
+
<tr bgcolor="<strong>#FFCCCC</strong>">
|
102
|
+
<td><strong>2</strong></td>
|
103
|
+
<td><strong>B&amp;B</strong></td>
|
104
|
+
</tr>
|
105
|
+
<tr bgcolor="<strong>#CCCCFF</strong>">
|
106
|
+
<td><strong>3</strong></td>
|
107
|
+
<td><strong>&quot;CCC&quot;</strong></td>
|
108
|
+
</tr>
|
109
|
+
</table>
|
110
|
+
</body>
|
111
|
+
</html>
|
112
|
+
</pre>
|
113
|
+
<br>
|
114
|
+
|
115
|
+
|
116
|
+
<a name="form"></a>
|
117
|
+
<h2 class="section1">Form</h2>
|
118
|
+
<a name="form/form.rbhtml"></a>
|
119
|
+
<div class="program_caption">
|
120
|
+
Template: 'form.rbhtml':</div>
|
121
|
+
<pre class="program"><strong><?rb #@ARGS action, params, label ?></strong>
|
122
|
+
<form action="<strong>${@action}</strong>" method="post">
|
123
|
+
<p>
|
124
|
+
<label>Name:</label>
|
125
|
+
<input type="text" name="name" value="<strong>${@params[:name]}</strong>" />
|
126
|
+
</p>
|
127
|
+
<p>
|
128
|
+
<label>Gender:</label>
|
129
|
+
<strong><?rb gender = @params[:gender] ?></strong>
|
130
|
+
<input type="radio" name="gender" value="M" <strong>#{checked(gender=='M')}</strong> />Man
|
131
|
+
<input type="radio" name="gender" value="W" <strong>#{checked(gender=='W')}</strong> />Woman
|
132
|
+
</p>
|
133
|
+
<input type="submit" value="<strong>${@label}</strong>" />
|
134
|
+
</form>
|
135
|
+
</pre>
|
136
|
+
<a name="form/create.rbhtml"></a>
|
137
|
+
<div class="program_caption">
|
138
|
+
Template: 'create.rbhtml':</div>
|
139
|
+
<pre class="program"><?rb @title = 'Create user' ?>
|
140
|
+
<?rb @label = 'Create' ?>
|
141
|
+
<?rb @action = 'action.cgi' ?>
|
142
|
+
<strong><?rb import(:form) ?></strong>
|
143
|
+
</pre>
|
144
|
+
<a name="form/update.rbhtml"></a>
|
145
|
+
<div class="program_caption">
|
146
|
+
Template: 'update.rbhtml':</div>
|
147
|
+
<pre class="program"><?rb @title = 'Update user' ?>
|
148
|
+
<?rb @label = 'Update' ?>
|
149
|
+
<?rb @action = 'update.cgi' ?>
|
150
|
+
<strong><?rb import(:form) ?></strong>
|
151
|
+
</pre>
|
152
|
+
<a name="form/layout.rbhtml"></a>
|
153
|
+
<div class="program_caption">
|
154
|
+
Layout template: 'layout.rbhtml'</div>
|
155
|
+
<pre class="program"><html>
|
156
|
+
<body>
|
157
|
+
<h1>${@title}</h1>
|
158
|
+
<div class="main-content">
|
159
|
+
<strong>#{@_content}</strong>
|
160
|
+
</div>
|
161
|
+
</body>
|
162
|
+
</html>
|
163
|
+
</pre>
|
164
|
+
<a name="form/main.rb"></a>
|
165
|
+
<div class="program_caption">
|
166
|
+
Main program: 'main.rb':</div>
|
167
|
+
<pre class="program">## create Engine object
|
168
|
+
require 'tenjin'
|
169
|
+
<strong>engine = Tenjin::Engine.new(:postfix=>'.rbhtml', :layout=>'layout.rbhtml')</strong>
|
170
|
+
|
171
|
+
## render template with context data
|
172
|
+
params = { :name=>'Foo', :gender=>'M' }
|
173
|
+
context = { :params=>params }
|
174
|
+
<strong>output = engine.render(:update, context)</strong> # :update == 'update'+postfix
|
175
|
+
puts output
|
176
|
+
</pre>
|
177
|
+
<a name="form/main.result"></a>
|
178
|
+
<div class="terminal_caption">
|
179
|
+
Result:</div>
|
180
|
+
<pre class="terminal">$ ruby main.rb
|
181
|
+
<html>
|
182
|
+
<body>
|
183
|
+
<h1><strong>Update user</strong></h1>
|
184
|
+
<div class="main-content">
|
185
|
+
<form action="<strong>update.cgi</strong>" method="post">
|
186
|
+
<p>
|
187
|
+
<label>Name:</label>
|
188
|
+
<input type="text" name="name" value="<strong>Foo</strong>" />
|
189
|
+
</p>
|
190
|
+
<p>
|
191
|
+
<label>Gender:</label>
|
192
|
+
<input type="radio" name="gender" value="M" <strong> checked="checked"</strong> />Man
|
193
|
+
<input type="radio" name="gender" value="W" />Woman
|
194
|
+
</p>
|
195
|
+
<input type="submit" value="<strong>Update</strong>" />
|
196
|
+
</form>
|
197
|
+
|
198
|
+
</div>
|
199
|
+
</body>
|
200
|
+
</html>
|
201
|
+
</pre>
|
202
|
+
<br>
|
203
|
+
|
204
|
+
|
205
|
+
<a name="preprocessing"></a>
|
206
|
+
<h2 class="section1">Preprocessing</h2>
|
207
|
+
<a name="preprocessing/helper.rb"></a>
|
208
|
+
<div class="program_caption">
|
209
|
+
Library: 'helper.rb'</div>
|
210
|
+
<pre class="program">LANGUAGES = [
|
211
|
+
['en', 'Engilish'],
|
212
|
+
['fr', 'French'],
|
213
|
+
['de', 'German'],
|
214
|
+
['es', 'Spanish'],
|
215
|
+
['ch', 'Chinese'],
|
216
|
+
['ja', 'Japanese'],
|
217
|
+
]
|
218
|
+
|
219
|
+
def link_to(label, options={})
|
220
|
+
action, id = options[:action], options[:id]
|
221
|
+
url = '/app'
|
222
|
+
url << '/' << action if action && !action.empty?
|
223
|
+
url << '/' << id if id
|
224
|
+
return "<a href=\"#{CGI::escape(url).gsub(/%2F/i, '/')}\">#{label}</a>"
|
225
|
+
end
|
226
|
+
</pre>
|
227
|
+
<a name="preprocessing/select.rbhtml"></a>
|
228
|
+
<div class="program_caption">
|
229
|
+
Template: 'select.rbhtml'</div>
|
230
|
+
<pre class="program"><?RB require 'helper' ?>
|
231
|
+
<form>
|
232
|
+
<label>Select your language:</label>
|
233
|
+
<select name="lang">
|
234
|
+
<?rb table = { @params[:lang] => ' selected="selected"' } ?>
|
235
|
+
<strong><?RB for val, name in LANGUAGES ?></strong>
|
236
|
+
<option value="${{val}}" #{table[#{{val.inspect}}]}>${{name}}</option>
|
237
|
+
<strong><?RB end ?></strong>
|
238
|
+
</select>
|
239
|
+
<input type="submit" value="OK" />
|
240
|
+
</form>
|
241
|
+
<p>
|
242
|
+
<strong>#{{</strong>link_to('Back', :action=>'index')<strong>}}</strong> |
|
243
|
+
<strong>#{{</strong>link_to('Show '+<strong>_P('@params[:name]')</strong>, :action=>'show', :id=><strong>_p('@params[:id]')</strong>)<strong>}}</strong>
|
244
|
+
</p>
|
245
|
+
</pre>
|
246
|
+
<a name="preprocessing/select_P.result"></a>
|
247
|
+
<div class="terminal_caption">
|
248
|
+
Preprocessed code:</div>
|
249
|
+
<pre class="terminal">$ rbtenjin -a preprocess select.rbhtml
|
250
|
+
<form>
|
251
|
+
<label>Select your language:</label>
|
252
|
+
<select name="lang">
|
253
|
+
<?rb table = { @params[:lang] => ' selected="selected"' } ?>
|
254
|
+
<option value="en" #{table["en"]}>Engilish</option>
|
255
|
+
<option value="fr" #{table["fr"]}>French</option>
|
256
|
+
<option value="de" #{table["de"]}>German</option>
|
257
|
+
<option value="es" #{table["es"]}>Spanish</option>
|
258
|
+
<option value="ch" #{table["ch"]}>Chinese</option>
|
259
|
+
<option value="ja" #{table["ja"]}>Japanese</option>
|
260
|
+
</select>
|
261
|
+
<input type="submit" value="OK" />
|
262
|
+
</form>
|
263
|
+
<p>
|
264
|
+
<a href="/app/index">Back</a> |
|
265
|
+
<a href="/app/show/<strong>#{@params[:id]}</strong>">Show <strong>${@params[:name]}</strong></a>
|
266
|
+
</p>
|
267
|
+
</pre>
|
268
|
+
<a name="preprocessing/main.rb"></a>
|
269
|
+
<div class="program_caption">
|
270
|
+
Main program: 'main.rb'</div>
|
271
|
+
<pre class="program">require 'helper'
|
272
|
+
|
273
|
+
## create engine
|
274
|
+
require 'tenjin'
|
275
|
+
engine = Tenjin::Engine.new(:postfix=>'.rbhtml', <strong>:preprocess=>true</strong>)
|
276
|
+
|
277
|
+
## render template with context data
|
278
|
+
params = { :id=>1234, :name=>'Foo', :lang=>'ch' }
|
279
|
+
context = { :params => params }
|
280
|
+
output = engine.render(:select, context)
|
281
|
+
puts output
|
282
|
+
</pre>
|
283
|
+
<a name="preprocessing/main.result"></a>
|
284
|
+
<div class="terminal_caption">
|
285
|
+
Result:</div>
|
286
|
+
<pre class="terminal">$ ruby main.rb
|
287
|
+
<form>
|
288
|
+
<label>Select your language:</label>
|
289
|
+
<select name="lang">
|
290
|
+
<option value="en" >Engilish</option>
|
291
|
+
<option value="fr" >French</option>
|
292
|
+
<option value="de" >German</option>
|
293
|
+
<option value="es" >Spanish</option>
|
294
|
+
<option value="ch" selected="selected">Chinese</option>
|
295
|
+
<option value="ja" >Japanese</option>
|
296
|
+
</select>
|
297
|
+
<input type="submit" value="OK" />
|
298
|
+
</form>
|
299
|
+
<p>
|
300
|
+
<a href="/app/index">Back</a> |
|
301
|
+
<a href="/app/show/1234">Show Foo</a>
|
302
|
+
</p>
|
303
|
+
</pre>
|
304
|
+
<br>
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
</div>
|
309
|
+
</blockquote>
|
310
|
+
|
311
|
+
</body>
|
312
|
+
</html>
|