tenjin 0.6.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/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
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: Tenjin::Preprocessor</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Tenjin::Preprocessor</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/tenjin_rb.html">
|
|
59
|
+
lib/tenjin.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="Template.html">
|
|
69
|
+
Template
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- banner header -->
|
|
76
|
+
|
|
77
|
+
<div id="bodyContent">
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div id="contextContent">
|
|
82
|
+
|
|
83
|
+
<div id="description">
|
|
84
|
+
<p>
|
|
85
|
+
preprocessor class
|
|
86
|
+
</p>
|
|
87
|
+
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div id="method-list">
|
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
|
95
|
+
|
|
96
|
+
<div class="name-list">
|
|
97
|
+
<a href="#M000044">add_expr</a>
|
|
98
|
+
<a href="#M000043">escape_str</a>
|
|
99
|
+
<a href="#M000042">expr_pattern</a>
|
|
100
|
+
<a href="#M000041">stmt_pattern</a>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
<!-- if includes -->
|
|
108
|
+
|
|
109
|
+
<div id="section">
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
<div id="constants-list">
|
|
113
|
+
<h3 class="section-bar">Constants</h3>
|
|
114
|
+
|
|
115
|
+
<div class="name-list">
|
|
116
|
+
<table summary="Constants">
|
|
117
|
+
<tr class="top-aligned-row context-row">
|
|
118
|
+
<td class="context-item-name">STMT_PATTERN</td>
|
|
119
|
+
<td>=</td>
|
|
120
|
+
<td class="context-item-value">compile_stmt_pattern('RB')</td>
|
|
121
|
+
</tr>
|
|
122
|
+
</table>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
<!-- if method_list -->
|
|
132
|
+
<div id="methods">
|
|
133
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
|
134
|
+
|
|
135
|
+
<div id="method-M000044" class="method-detail">
|
|
136
|
+
<a name="M000044"></a>
|
|
137
|
+
|
|
138
|
+
<div class="method-heading">
|
|
139
|
+
<a href="#M000044" class="method-signature">
|
|
140
|
+
<span class="method-name">add_expr</span><span class="method-args">(code, flag_escape=nil)</span>
|
|
141
|
+
</a>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div class="method-description">
|
|
145
|
+
<p><a class="source-toggle" href="#"
|
|
146
|
+
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
|
147
|
+
<div class="method-source-code" id="M000044-source">
|
|
148
|
+
<pre>
|
|
149
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 650</span>
|
|
150
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">flag_escape</span>=<span class="ruby-keyword kw">nil</span>)
|
|
151
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">code</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">empty?</span>
|
|
152
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-node">"_decode_params((#{code}))"</span>, <span class="ruby-identifier">flag_escape</span>)
|
|
153
|
+
<span class="ruby-keyword kw">end</span>
|
|
154
|
+
</pre>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div id="method-M000043" class="method-detail">
|
|
160
|
+
<a name="M000043"></a>
|
|
161
|
+
|
|
162
|
+
<div class="method-heading">
|
|
163
|
+
<a href="#M000043" class="method-signature">
|
|
164
|
+
<span class="method-name">escape_str</span><span class="method-args">(str)</span>
|
|
165
|
+
</a>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div class="method-description">
|
|
169
|
+
<p><a class="source-toggle" href="#"
|
|
170
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
|
171
|
+
<div class="method-source-code" id="M000043-source">
|
|
172
|
+
<pre>
|
|
173
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 644</span>
|
|
174
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">str</span>)
|
|
175
|
+
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[\\`\#]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
|
176
|
+
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n/</span>, <span class="ruby-value str">"\\r\r\n"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@newline</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"\r\n"</span>
|
|
177
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>
|
|
178
|
+
<span class="ruby-keyword kw">end</span>
|
|
179
|
+
</pre>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div id="method-M000042" class="method-detail">
|
|
185
|
+
<a name="M000042"></a>
|
|
186
|
+
|
|
187
|
+
<div class="method-heading">
|
|
188
|
+
<a href="#M000042" class="method-signature">
|
|
189
|
+
<span class="method-name">expr_pattern</span><span class="method-args">()</span>
|
|
190
|
+
</a>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<div class="method-description">
|
|
194
|
+
<p><a class="source-toggle" href="#"
|
|
195
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
|
196
|
+
<div class="method-source-code" id="M000042-source">
|
|
197
|
+
<pre>
|
|
198
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 634</span>
|
|
199
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expr_pattern</span>
|
|
200
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-regexp re">/([\#$])\{\{(.*?)\}\}/</span><span class="ruby-identifier">m</span>
|
|
201
|
+
<span class="ruby-keyword kw">end</span>
|
|
202
|
+
</pre>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<div id="method-M000041" class="method-detail">
|
|
208
|
+
<a name="M000041"></a>
|
|
209
|
+
|
|
210
|
+
<div class="method-heading">
|
|
211
|
+
<a href="#M000041" class="method-signature">
|
|
212
|
+
<span class="method-name">stmt_pattern</span><span class="method-args">()</span>
|
|
213
|
+
</a>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<div class="method-description">
|
|
217
|
+
<p><a class="source-toggle" href="#"
|
|
218
|
+
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
|
219
|
+
<div class="method-source-code" id="M000041-source">
|
|
220
|
+
<pre>
|
|
221
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 630</span>
|
|
222
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stmt_pattern</span>
|
|
223
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">STMT_PATTERN</span>
|
|
224
|
+
<span class="ruby-keyword kw">end</span>
|
|
225
|
+
</pre>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
<div id="validator-badges">
|
|
238
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
</body>
|
|
242
|
+
</html>
|
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: Tenjin::Template</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Tenjin::Template</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/tenjin_rb.html">
|
|
59
|
+
lib/tenjin.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
Object
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
</table>
|
|
72
|
+
</div>
|
|
73
|
+
<!-- banner header -->
|
|
74
|
+
|
|
75
|
+
<div id="bodyContent">
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<div id="contextContent">
|
|
80
|
+
|
|
81
|
+
<div id="description">
|
|
82
|
+
<p>
|
|
83
|
+
template class
|
|
84
|
+
</p>
|
|
85
|
+
<p>
|
|
86
|
+
ex. file ‘example.rbhtml‘
|
|
87
|
+
</p>
|
|
88
|
+
<pre>
|
|
89
|
+
<html>
|
|
90
|
+
<body>
|
|
91
|
+
<h1>${@title}</h1>
|
|
92
|
+
<ul>
|
|
93
|
+
<?rb i = 0 ?>
|
|
94
|
+
<?rb for item in @items ?>
|
|
95
|
+
<?rb i += 1 ?>
|
|
96
|
+
<li>#{i} : ${item}</li>
|
|
97
|
+
<?rb end ?>
|
|
98
|
+
</ul>
|
|
99
|
+
</body>
|
|
100
|
+
</html>
|
|
101
|
+
</pre>
|
|
102
|
+
<p>
|
|
103
|
+
ex. convertion
|
|
104
|
+
</p>
|
|
105
|
+
<pre>
|
|
106
|
+
require 'tenjin'
|
|
107
|
+
template = Tenjin::Template.new('example.rbhtml')
|
|
108
|
+
print template.script
|
|
109
|
+
## or
|
|
110
|
+
# template = Tenjin::Template.new()
|
|
111
|
+
# print template.convert_file('example.rbhtml')
|
|
112
|
+
## or
|
|
113
|
+
# template = Tenjin::Template.new()
|
|
114
|
+
# fname = 'example.rbhtml'
|
|
115
|
+
# print template.convert(File.read(fname), fname) # filename is optional
|
|
116
|
+
</pre>
|
|
117
|
+
<p>
|
|
118
|
+
ex. evaluation
|
|
119
|
+
</p>
|
|
120
|
+
<pre>
|
|
121
|
+
context = {:title=>'Tenjin Example', :items=>['foo', 'bar', 'baz'] }
|
|
122
|
+
output = template.render(context)
|
|
123
|
+
## or
|
|
124
|
+
# context = Tenjin::Context(:title=>'Tenjin Example', :items=>['foo','bar','baz'])
|
|
125
|
+
# output = template.render(context)
|
|
126
|
+
## or
|
|
127
|
+
# output = template.render(:title=>'Tenjin Example', :items=>['foo','bar','baz'])
|
|
128
|
+
print output
|
|
129
|
+
</pre>
|
|
130
|
+
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<div id="method-list">
|
|
137
|
+
<h3 class="section-bar">Methods</h3>
|
|
138
|
+
|
|
139
|
+
<div class="name-list">
|
|
140
|
+
<a href="#M000061">add_expr</a>
|
|
141
|
+
<a href="#M000062">add_stmt</a>
|
|
142
|
+
<a href="#M000059">add_text</a>
|
|
143
|
+
<a href="#M000049">after_convert</a>
|
|
144
|
+
<a href="#M000048">before_convert</a>
|
|
145
|
+
<a href="#M000050">compile_stmt_pattern</a>
|
|
146
|
+
<a href="#M000047">convert</a>
|
|
147
|
+
<a href="#M000046">convert_file</a>
|
|
148
|
+
<a href="#M000060">escape_str</a>
|
|
149
|
+
<a href="#M000053">expr_pattern</a>
|
|
150
|
+
<a href="#M000054">get_expr_and_escapeflag</a>
|
|
151
|
+
<a href="#M000045">new</a>
|
|
152
|
+
<a href="#M000055">parse_exprs</a>
|
|
153
|
+
<a href="#M000052">parse_stmts</a>
|
|
154
|
+
<a href="#M000063">render</a>
|
|
155
|
+
<a href="#M000057">start_text_part</a>
|
|
156
|
+
<a href="#M000056">statement_hook</a>
|
|
157
|
+
<a href="#M000051">stmt_pattern</a>
|
|
158
|
+
<a href="#M000058">stop_text_part</a>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
<!-- if includes -->
|
|
166
|
+
|
|
167
|
+
<div id="section">
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<div id="constants-list">
|
|
171
|
+
<h3 class="section-bar">Constants</h3>
|
|
172
|
+
|
|
173
|
+
<div class="name-list">
|
|
174
|
+
<table summary="Constants">
|
|
175
|
+
<tr class="top-aligned-row context-row">
|
|
176
|
+
<td class="context-item-name">ESCAPE_FUNCTION</td>
|
|
177
|
+
<td>=</td>
|
|
178
|
+
<td class="context-item-value">'escape'</td>
|
|
179
|
+
</tr>
|
|
180
|
+
<tr class="top-aligned-row context-row">
|
|
181
|
+
<td class="context-item-name">STMT_PATTERN</td>
|
|
182
|
+
<td>=</td>
|
|
183
|
+
<td class="context-item-value">self.compile_stmt_pattern('rb')</td>
|
|
184
|
+
</tr>
|
|
185
|
+
</table>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
<div id="attribute-list">
|
|
192
|
+
<h3 class="section-bar">Attributes</h3>
|
|
193
|
+
|
|
194
|
+
<div class="name-list">
|
|
195
|
+
<table>
|
|
196
|
+
<tr class="top-aligned-row context-row">
|
|
197
|
+
<td class="context-item-name">args</td>
|
|
198
|
+
<td class="context-item-value"> [RW] </td>
|
|
199
|
+
<td class="context-item-desc"></td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr class="top-aligned-row context-row">
|
|
202
|
+
<td class="context-item-name">escapefunc</td>
|
|
203
|
+
<td class="context-item-value"> [RW] </td>
|
|
204
|
+
<td class="context-item-desc"></td>
|
|
205
|
+
</tr>
|
|
206
|
+
<tr class="top-aligned-row context-row">
|
|
207
|
+
<td class="context-item-name">filename</td>
|
|
208
|
+
<td class="context-item-value"> [RW] </td>
|
|
209
|
+
<td class="context-item-desc"></td>
|
|
210
|
+
</tr>
|
|
211
|
+
<tr class="top-aligned-row context-row">
|
|
212
|
+
<td class="context-item-name">initbuf</td>
|
|
213
|
+
<td class="context-item-value"> [RW] </td>
|
|
214
|
+
<td class="context-item-desc"></td>
|
|
215
|
+
</tr>
|
|
216
|
+
<tr class="top-aligned-row context-row">
|
|
217
|
+
<td class="context-item-name">newline</td>
|
|
218
|
+
<td class="context-item-value"> [RW] </td>
|
|
219
|
+
<td class="context-item-desc"></td>
|
|
220
|
+
</tr>
|
|
221
|
+
<tr class="top-aligned-row context-row">
|
|
222
|
+
<td class="context-item-name">script</td>
|
|
223
|
+
<td class="context-item-value"> [RW] </td>
|
|
224
|
+
<td class="context-item-desc"></td>
|
|
225
|
+
</tr>
|
|
226
|
+
<tr class="top-aligned-row context-row">
|
|
227
|
+
<td class="context-item-name">timestamp</td>
|
|
228
|
+
<td class="context-item-value"> [RW] </td>
|
|
229
|
+
<td class="context-item-desc"></td>
|
|
230
|
+
</tr>
|
|
231
|
+
</table>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
<!-- if method_list -->
|
|
238
|
+
<div id="methods">
|
|
239
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
240
|
+
|
|
241
|
+
<div id="method-M000045" class="method-detail">
|
|
242
|
+
<a name="M000045"></a>
|
|
243
|
+
|
|
244
|
+
<div class="method-heading">
|
|
245
|
+
<a href="#M000045" class="method-signature">
|
|
246
|
+
<span class="method-name">new</span><span class="method-args">(filename=nil, options={})</span>
|
|
247
|
+
</a>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div class="method-description">
|
|
251
|
+
<p>
|
|
252
|
+
initializer of <a href="Template.html">Template</a> class.
|
|
253
|
+
</p>
|
|
254
|
+
<p>
|
|
255
|
+
options:
|
|
256
|
+
</p>
|
|
257
|
+
<table>
|
|
258
|
+
<tr><td valign="top">:escapefunc :</td><td>function name to escape value (default ‘escape’)
|
|
259
|
+
|
|
260
|
+
</td></tr>
|
|
261
|
+
<tr><td valign="top">:preamble :</td><td>preamble such as "_buf = ’’" (default nil)
|
|
262
|
+
|
|
263
|
+
</td></tr>
|
|
264
|
+
<tr><td valign="top">:postamble :</td><td>postamble such as "_buf.to_s" (default nil)
|
|
265
|
+
|
|
266
|
+
</td></tr>
|
|
267
|
+
</table>
|
|
268
|
+
<p><a class="source-toggle" href="#"
|
|
269
|
+
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
|
270
|
+
<div class="method-source-code" id="M000045-source">
|
|
271
|
+
<pre>
|
|
272
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 327</span>
|
|
273
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>={})
|
|
274
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
275
|
+
<span class="ruby-identifier">options</span> = <span class="ruby-identifier">filename</span>
|
|
276
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-keyword kw">nil</span>
|
|
277
|
+
<span class="ruby-keyword kw">end</span>
|
|
278
|
+
<span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">filename</span>
|
|
279
|
+
<span class="ruby-ivar">@escapefunc</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:escapefunc</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">ESCAPE_FUNCTION</span>
|
|
280
|
+
<span class="ruby-ivar">@preamble</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preamble</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-node">"_buf = #{init_buf_expr()}; "</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preamble</span>]
|
|
281
|
+
<span class="ruby-ivar">@postamble</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:postamble</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"_buf.to_s"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:postamble</span>]
|
|
282
|
+
<span class="ruby-ivar">@args</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># or array of argument names</span>
|
|
283
|
+
<span class="ruby-identifier">convert_file</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filename</span>
|
|
284
|
+
<span class="ruby-keyword kw">end</span>
|
|
285
|
+
</pre>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
<h3 class="section-bar">Protected Class methods</h3>
|
|
291
|
+
|
|
292
|
+
<div id="method-M000050" class="method-detail">
|
|
293
|
+
<a name="M000050"></a>
|
|
294
|
+
|
|
295
|
+
<div class="method-heading">
|
|
296
|
+
<a href="#M000050" class="method-signature">
|
|
297
|
+
<span class="method-name">compile_stmt_pattern</span><span class="method-args">(pi)</span>
|
|
298
|
+
</a>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<div class="method-description">
|
|
302
|
+
<p><a class="source-toggle" href="#"
|
|
303
|
+
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
|
304
|
+
<div class="method-source-code" id="M000050-source">
|
|
305
|
+
<pre>
|
|
306
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 381</span>
|
|
307
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">compile_stmt_pattern</span>(<span class="ruby-identifier">pi</span>)
|
|
308
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-node">/<\?#{pi}( |\t|\r?\n)(.*?) ?\?>([ \t]*\r?\n)?/</span><span class="ruby-identifier">m</span>
|
|
309
|
+
<span class="ruby-keyword kw">end</span>
|
|
310
|
+
</pre>
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
316
|
+
|
|
317
|
+
<div id="method-M000047" class="method-detail">
|
|
318
|
+
<a name="M000047"></a>
|
|
319
|
+
|
|
320
|
+
<div class="method-heading">
|
|
321
|
+
<a href="#M000047" class="method-signature">
|
|
322
|
+
<span class="method-name">convert</span><span class="method-args">(input, filename=nil)</span>
|
|
323
|
+
</a>
|
|
324
|
+
</div>
|
|
325
|
+
|
|
326
|
+
<div class="method-description">
|
|
327
|
+
<p>
|
|
328
|
+
<a href="Template.html#M000047">convert</a> string into ruby code
|
|
329
|
+
</p>
|
|
330
|
+
<p><a class="source-toggle" href="#"
|
|
331
|
+
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
|
332
|
+
<div class="method-source-code" id="M000047-source">
|
|
333
|
+
<pre>
|
|
334
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 349</span>
|
|
335
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-keyword kw">nil</span>)
|
|
336
|
+
<span class="ruby-ivar">@input</span> = <span class="ruby-identifier">input</span>
|
|
337
|
+
<span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">filename</span>
|
|
338
|
+
<span class="ruby-ivar">@proc</span> = <span class="ruby-keyword kw">nil</span>
|
|
339
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value">?\n</span>)
|
|
340
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pos</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\r</span>
|
|
341
|
+
<span class="ruby-ivar">@newline</span> = <span class="ruby-value str">"\r\n"</span>
|
|
342
|
+
<span class="ruby-ivar">@newlinestr</span> = <span class="ruby-value str">'\\r\\n'</span>
|
|
343
|
+
<span class="ruby-keyword kw">else</span>
|
|
344
|
+
<span class="ruby-ivar">@newline</span> = <span class="ruby-value str">"\n"</span>
|
|
345
|
+
<span class="ruby-ivar">@newlinestr</span> = <span class="ruby-value str">'\\n'</span>
|
|
346
|
+
<span class="ruby-keyword kw">end</span>
|
|
347
|
+
<span class="ruby-identifier">before_convert</span>()
|
|
348
|
+
<span class="ruby-identifier">parse_stmts</span>(<span class="ruby-identifier">input</span>)
|
|
349
|
+
<span class="ruby-identifier">after_convert</span>()
|
|
350
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@script</span>
|
|
351
|
+
<span class="ruby-keyword kw">end</span>
|
|
352
|
+
</pre>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
<div id="method-M000046" class="method-detail">
|
|
358
|
+
<a name="M000046"></a>
|
|
359
|
+
|
|
360
|
+
<div class="method-heading">
|
|
361
|
+
<a href="#M000046" class="method-signature">
|
|
362
|
+
<span class="method-name">convert_file</span><span class="method-args">(filename)</span>
|
|
363
|
+
</a>
|
|
364
|
+
</div>
|
|
365
|
+
|
|
366
|
+
<div class="method-description">
|
|
367
|
+
<p>
|
|
368
|
+
<a href="Template.html#M000047">convert</a> file into ruby code
|
|
369
|
+
</p>
|
|
370
|
+
<p><a class="source-toggle" href="#"
|
|
371
|
+
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
|
372
|
+
<div class="method-source-code" id="M000046-source">
|
|
373
|
+
<pre>
|
|
374
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 344</span>
|
|
375
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert_file</span>(<span class="ruby-identifier">filename</span>)
|
|
376
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">convert</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">filename</span>)
|
|
377
|
+
<span class="ruby-keyword kw">end</span>
|
|
378
|
+
</pre>
|
|
379
|
+
</div>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
|
|
383
|
+
<div id="method-M000063" class="method-detail">
|
|
384
|
+
<a name="M000063"></a>
|
|
385
|
+
|
|
386
|
+
<div class="method-heading">
|
|
387
|
+
<a href="#M000063" class="method-signature">
|
|
388
|
+
<span class="method-name">render</span><span class="method-args">(context=Context.new)</span>
|
|
389
|
+
</a>
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div class="method-description">
|
|
393
|
+
<p>
|
|
394
|
+
evaluate converted ruby code and return it. argument ‘_context’
|
|
395
|
+
should be a Hash object or <a href="Context.html">Context</a> object.
|
|
396
|
+
</p>
|
|
397
|
+
<p><a class="source-toggle" href="#"
|
|
398
|
+
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
|
399
|
+
<div class="method-source-code" id="M000063-source">
|
|
400
|
+
<pre>
|
|
401
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 612</span>
|
|
402
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">context</span>=<span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>)
|
|
403
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">context</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
|
404
|
+
<span class="ruby-ivar">@proc</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">_render</span>()
|
|
405
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-ivar">@proc</span>)
|
|
406
|
+
<span class="ruby-keyword kw">end</span>
|
|
407
|
+
</pre>
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
|
413
|
+
|
|
414
|
+
<div id="method-M000061" class="method-detail">
|
|
415
|
+
<a name="M000061"></a>
|
|
416
|
+
|
|
417
|
+
<div class="method-heading">
|
|
418
|
+
<a href="#M000061" class="method-signature">
|
|
419
|
+
<span class="method-name">add_expr</span><span class="method-args">(code, flag_escape=nil)</span>
|
|
420
|
+
</a>
|
|
421
|
+
</div>
|
|
422
|
+
|
|
423
|
+
<div class="method-description">
|
|
424
|
+
<p>
|
|
425
|
+
add expression code
|
|
426
|
+
</p>
|
|
427
|
+
<p><a class="source-toggle" href="#"
|
|
428
|
+
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
|
429
|
+
<div class="method-source-code" id="M000061-source">
|
|
430
|
+
<pre>
|
|
431
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 587</span>
|
|
432
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">flag_escape</span>=<span class="ruby-keyword kw">nil</span>)
|
|
433
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">code</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">empty?</span>
|
|
434
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">flag_escape</span> <span class="ruby-value">? </span><span class="ruby-node">"\#{#{@escapefunc}((#{code}).to_s)}"</span> <span class="ruby-operator">:</span> <span class="ruby-node">"\#{#{code}}"</span>)
|
|
435
|
+
<span class="ruby-keyword kw">end</span>
|
|
436
|
+
</pre>
|
|
437
|
+
</div>
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
|
|
441
|
+
<div id="method-M000062" class="method-detail">
|
|
442
|
+
<a name="M000062"></a>
|
|
443
|
+
|
|
444
|
+
<div class="method-heading">
|
|
445
|
+
<a href="#M000062" class="method-signature">
|
|
446
|
+
<span class="method-name">add_stmt</span><span class="method-args">(code)</span>
|
|
447
|
+
</a>
|
|
448
|
+
</div>
|
|
449
|
+
|
|
450
|
+
<div class="method-description">
|
|
451
|
+
<p>
|
|
452
|
+
add statement code
|
|
453
|
+
</p>
|
|
454
|
+
<p><a class="source-toggle" href="#"
|
|
455
|
+
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
|
456
|
+
<div class="method-source-code" id="M000062-source">
|
|
457
|
+
<pre>
|
|
458
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 593</span>
|
|
459
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">code</span>)
|
|
460
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span>
|
|
461
|
+
<span class="ruby-keyword kw">end</span>
|
|
462
|
+
</pre>
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<div id="method-M000059" class="method-detail">
|
|
468
|
+
<a name="M000059"></a>
|
|
469
|
+
|
|
470
|
+
<div class="method-heading">
|
|
471
|
+
<a href="#M000059" class="method-signature">
|
|
472
|
+
<span class="method-name">add_text</span><span class="method-args">(text, encode_newline=false)</span>
|
|
473
|
+
</a>
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
<div class="method-description">
|
|
477
|
+
<p>
|
|
478
|
+
add text string
|
|
479
|
+
</p>
|
|
480
|
+
<p><a class="source-toggle" href="#"
|
|
481
|
+
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
|
482
|
+
<div class="method-source-code" id="M000059-source">
|
|
483
|
+
<pre>
|
|
484
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 569</span>
|
|
485
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">encode_newline</span>=<span class="ruby-keyword kw">false</span>)
|
|
486
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
|
487
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">encode_newline</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">text</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
488
|
+
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">chomp!</span>
|
|
489
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">text</span>) <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newlinestr</span>
|
|
490
|
+
<span class="ruby-keyword kw">else</span>
|
|
491
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">text</span>)
|
|
492
|
+
<span class="ruby-keyword kw">end</span>
|
|
493
|
+
<span class="ruby-keyword kw">end</span>
|
|
494
|
+
</pre>
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
|
|
499
|
+
<div id="method-M000049" class="method-detail">
|
|
500
|
+
<a name="M000049"></a>
|
|
501
|
+
|
|
502
|
+
<div class="method-heading">
|
|
503
|
+
<a href="#M000049" class="method-signature">
|
|
504
|
+
<span class="method-name">after_convert</span><span class="method-args">()</span>
|
|
505
|
+
</a>
|
|
506
|
+
</div>
|
|
507
|
+
|
|
508
|
+
<div class="method-description">
|
|
509
|
+
<p>
|
|
510
|
+
hook method called after <a href="Template.html#M000047">convert</a>()
|
|
511
|
+
</p>
|
|
512
|
+
<p><a class="source-toggle" href="#"
|
|
513
|
+
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
|
514
|
+
<div class="method-source-code" id="M000049-source">
|
|
515
|
+
<pre>
|
|
516
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 376</span>
|
|
517
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_convert</span>()
|
|
518
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newline</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@script</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
519
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@postamble</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@newline</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@postamble</span>
|
|
520
|
+
<span class="ruby-keyword kw">end</span>
|
|
521
|
+
</pre>
|
|
522
|
+
</div>
|
|
523
|
+
</div>
|
|
524
|
+
</div>
|
|
525
|
+
|
|
526
|
+
<div id="method-M000048" class="method-detail">
|
|
527
|
+
<a name="M000048"></a>
|
|
528
|
+
|
|
529
|
+
<div class="method-heading">
|
|
530
|
+
<a href="#M000048" class="method-signature">
|
|
531
|
+
<span class="method-name">before_convert</span><span class="method-args">()</span>
|
|
532
|
+
</a>
|
|
533
|
+
</div>
|
|
534
|
+
|
|
535
|
+
<div class="method-description">
|
|
536
|
+
<p>
|
|
537
|
+
hook method called before <a href="Template.html#M000047">convert</a>()
|
|
538
|
+
</p>
|
|
539
|
+
<p><a class="source-toggle" href="#"
|
|
540
|
+
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
|
541
|
+
<div class="method-source-code" id="M000048-source">
|
|
542
|
+
<pre>
|
|
543
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 370</span>
|
|
544
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before_convert</span>()
|
|
545
|
+
<span class="ruby-ivar">@script</span> = <span class="ruby-value str">''</span>
|
|
546
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@preamble</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@preamble</span>
|
|
547
|
+
<span class="ruby-keyword kw">end</span>
|
|
548
|
+
</pre>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
</div>
|
|
552
|
+
|
|
553
|
+
<div id="method-M000060" class="method-detail">
|
|
554
|
+
<a name="M000060"></a>
|
|
555
|
+
|
|
556
|
+
<div class="method-heading">
|
|
557
|
+
<a href="#M000060" class="method-signature">
|
|
558
|
+
<span class="method-name">escape_str</span><span class="method-args">(str)</span>
|
|
559
|
+
</a>
|
|
560
|
+
</div>
|
|
561
|
+
|
|
562
|
+
<div class="method-description">
|
|
563
|
+
<p>
|
|
564
|
+
escape ’\’ and ’`’ into ’\\’ and
|
|
565
|
+
’\`’
|
|
566
|
+
</p>
|
|
567
|
+
<p><a class="source-toggle" href="#"
|
|
568
|
+
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
|
569
|
+
<div class="method-source-code" id="M000060-source">
|
|
570
|
+
<pre>
|
|
571
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 580</span>
|
|
572
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_str</span>(<span class="ruby-identifier">str</span>)
|
|
573
|
+
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[`\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>)
|
|
574
|
+
<span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\r\n/</span>, <span class="ruby-value str">"\\r\r\n"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@newline</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"\r\n"</span>
|
|
575
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">str</span>
|
|
576
|
+
<span class="ruby-keyword kw">end</span>
|
|
577
|
+
</pre>
|
|
578
|
+
</div>
|
|
579
|
+
</div>
|
|
580
|
+
</div>
|
|
581
|
+
|
|
582
|
+
<div id="method-M000053" class="method-detail">
|
|
583
|
+
<a name="M000053"></a>
|
|
584
|
+
|
|
585
|
+
<div class="method-heading">
|
|
586
|
+
<a href="#M000053" class="method-signature">
|
|
587
|
+
<span class="method-name">expr_pattern</span><span class="method-args">()</span>
|
|
588
|
+
</a>
|
|
589
|
+
</div>
|
|
590
|
+
|
|
591
|
+
<div class="method-description">
|
|
592
|
+
<p><a class="source-toggle" href="#"
|
|
593
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
|
594
|
+
<div class="method-source-code" id="M000053-source">
|
|
595
|
+
<pre>
|
|
596
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 454</span>
|
|
597
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expr_pattern</span>
|
|
598
|
+
<span class="ruby-comment cmt">#return /([\#$])\{(.*?)\}/</span>
|
|
599
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-regexp re">/(\$)\{(.*?)\}/</span><span class="ruby-identifier">m</span>
|
|
600
|
+
<span class="ruby-comment cmt">#return /\$\{.*?\}/</span>
|
|
601
|
+
<span class="ruby-keyword kw">end</span>
|
|
602
|
+
</pre>
|
|
603
|
+
</div>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
|
|
607
|
+
<div id="method-M000054" class="method-detail">
|
|
608
|
+
<a name="M000054"></a>
|
|
609
|
+
|
|
610
|
+
<div class="method-heading">
|
|
611
|
+
<a href="#M000054" class="method-signature">
|
|
612
|
+
<span class="method-name">get_expr_and_escapeflag</span><span class="method-args">(matched)</span>
|
|
613
|
+
</a>
|
|
614
|
+
</div>
|
|
615
|
+
|
|
616
|
+
<div class="method-description">
|
|
617
|
+
<p>
|
|
618
|
+
ex. <a
|
|
619
|
+
href="Template.html#M000054">get_expr_and_escapeflag</a>(’$’,
|
|
620
|
+
‘item[:name]’) => ‘item[:name]’, true
|
|
621
|
+
</p>
|
|
622
|
+
<p><a class="source-toggle" href="#"
|
|
623
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
|
624
|
+
<div class="method-source-code" id="M000054-source">
|
|
625
|
+
<pre>
|
|
626
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 461</span>
|
|
627
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_expr_and_escapeflag</span>(<span class="ruby-identifier">matched</span>)
|
|
628
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">matched</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">matched</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'$'</span>
|
|
629
|
+
<span class="ruby-keyword kw">end</span>
|
|
630
|
+
</pre>
|
|
631
|
+
</div>
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
|
|
635
|
+
<div id="method-M000055" class="method-detail">
|
|
636
|
+
<a name="M000055"></a>
|
|
637
|
+
|
|
638
|
+
<div class="method-heading">
|
|
639
|
+
<a href="#M000055" class="method-signature">
|
|
640
|
+
<span class="method-name">parse_exprs</span><span class="method-args">(input)</span>
|
|
641
|
+
</a>
|
|
642
|
+
</div>
|
|
643
|
+
|
|
644
|
+
<div class="method-description">
|
|
645
|
+
<p>
|
|
646
|
+
parse expressions (’#{…}’ and ’${…}’)
|
|
647
|
+
</p>
|
|
648
|
+
<p><a class="source-toggle" href="#"
|
|
649
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
|
650
|
+
<div class="method-source-code" id="M000055-source">
|
|
651
|
+
<pre>
|
|
652
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 466</span>
|
|
653
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">input</span>)
|
|
654
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">input</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">empty?</span>
|
|
655
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
|
656
|
+
<span class="ruby-identifier">start_text_part</span>()
|
|
657
|
+
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">expr_pattern</span>()) <span class="ruby-keyword kw">do</span>
|
|
658
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
|
659
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>]
|
|
660
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
|
661
|
+
<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">flag_escape</span> = <span class="ruby-identifier">get_expr_and_escapeflag</span>(<span class="ruby-identifier">m</span>)
|
|
662
|
+
<span class="ruby-comment cmt">#m = Regexp.last_match</span>
|
|
663
|
+
<span class="ruby-comment cmt">#start = m.begin(0)</span>
|
|
664
|
+
<span class="ruby-comment cmt">#stop = m.end(0)</span>
|
|
665
|
+
<span class="ruby-comment cmt">#text = input[pos, start - pos]</span>
|
|
666
|
+
<span class="ruby-comment cmt">#expr = input[start+2, stop-start-3]</span>
|
|
667
|
+
<span class="ruby-comment cmt">#pos = stop</span>
|
|
668
|
+
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">text</span>)
|
|
669
|
+
<span class="ruby-identifier">add_expr</span>(<span class="ruby-identifier">expr</span>, <span class="ruby-identifier">flag_escape</span>)
|
|
670
|
+
<span class="ruby-keyword kw">end</span>
|
|
671
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">input</span>
|
|
672
|
+
<span class="ruby-comment cmt">#if !rest || rest.empty?</span>
|
|
673
|
+
<span class="ruby-comment cmt"># @script << '`; '</span>
|
|
674
|
+
<span class="ruby-comment cmt">#elsif rest[-1] == ?\n</span>
|
|
675
|
+
<span class="ruby-comment cmt"># rest.chomp!</span>
|
|
676
|
+
<span class="ruby-comment cmt"># @script << escape_str(rest) << @newlinestr << '`' << @newline</span>
|
|
677
|
+
<span class="ruby-comment cmt">#else</span>
|
|
678
|
+
<span class="ruby-comment cmt"># @script << escape_str(rest) << '`; '</span>
|
|
679
|
+
<span class="ruby-comment cmt">#end</span>
|
|
680
|
+
<span class="ruby-identifier">flag_newline</span> = <span class="ruby-identifier">input</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
681
|
+
<span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">rest</span>, <span class="ruby-keyword kw">true</span>)
|
|
682
|
+
<span class="ruby-identifier">stop_text_part</span>()
|
|
683
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">flag_newline</span> <span class="ruby-value">? </span><span class="ruby-ivar">@newline</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'; '</span>)
|
|
684
|
+
<span class="ruby-keyword kw">end</span>
|
|
685
|
+
</pre>
|
|
686
|
+
</div>
|
|
687
|
+
</div>
|
|
688
|
+
</div>
|
|
689
|
+
|
|
690
|
+
<div id="method-M000052" class="method-detail">
|
|
691
|
+
<a name="M000052"></a>
|
|
692
|
+
|
|
693
|
+
<div class="method-heading">
|
|
694
|
+
<a href="#M000052" class="method-signature">
|
|
695
|
+
<span class="method-name">parse_stmts</span><span class="method-args">(input)</span>
|
|
696
|
+
</a>
|
|
697
|
+
</div>
|
|
698
|
+
|
|
699
|
+
<div class="method-description">
|
|
700
|
+
<p>
|
|
701
|
+
parse statements (’<?rb … ?>’)
|
|
702
|
+
</p>
|
|
703
|
+
<p><a class="source-toggle" href="#"
|
|
704
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
|
705
|
+
<div class="method-source-code" id="M000052-source">
|
|
706
|
+
<pre>
|
|
707
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 392</span>
|
|
708
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_stmts</span>(<span class="ruby-identifier">input</span>)
|
|
709
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">input</span>
|
|
710
|
+
<span class="ruby-identifier">is_bol</span> = <span class="ruby-keyword kw">true</span>
|
|
711
|
+
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-keyword kw">nil</span>
|
|
712
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
|
713
|
+
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">stmt_pattern</span>()) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mspace</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
|
|
714
|
+
<span class="ruby-identifier">m</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
|
715
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">m</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>]
|
|
716
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
|
717
|
+
<span class="ruby-comment cmt">## detect spaces at beginning of line</span>
|
|
718
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-keyword kw">nil</span>
|
|
719
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>.<span class="ruby-identifier">nil?</span>
|
|
720
|
+
<span class="ruby-comment cmt"># nothing</span>
|
|
721
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
|
|
722
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span>
|
|
723
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">text</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
724
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-value str">""</span>
|
|
725
|
+
<span class="ruby-keyword kw">else</span>
|
|
726
|
+
<span class="ruby-identifier">rindex</span> = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value">?\n</span>)
|
|
727
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rindex</span>
|
|
728
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">text</span>[<span class="ruby-identifier">rindex</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
|
|
729
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
|
|
730
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">s</span>
|
|
731
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">text</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">rindex</span>]
|
|
732
|
+
<span class="ruby-comment cmt">#text[rindex+1..-1] = ''</span>
|
|
733
|
+
<span class="ruby-keyword kw">end</span>
|
|
734
|
+
<span class="ruby-keyword kw">else</span>
|
|
735
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_bol</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">text</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[ \t]*\z/</span>
|
|
736
|
+
<span class="ruby-identifier">lspace</span> = <span class="ruby-identifier">text</span>
|
|
737
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">nil</span>
|
|
738
|
+
<span class="ruby-comment cmt">#lspace = text.dup</span>
|
|
739
|
+
<span class="ruby-comment cmt">#text[0..-1] = ''</span>
|
|
740
|
+
<span class="ruby-keyword kw">end</span>
|
|
741
|
+
<span class="ruby-keyword kw">end</span>
|
|
742
|
+
<span class="ruby-keyword kw">end</span>
|
|
743
|
+
<span class="ruby-identifier">is_bol</span> = <span class="ruby-identifier">rspace</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
|
744
|
+
<span class="ruby-comment cmt">##</span>
|
|
745
|
+
<span class="ruby-identifier">text</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">prev_rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prev_rspace</span>
|
|
746
|
+
<span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">text</span>)
|
|
747
|
+
<span class="ruby-identifier">code</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">mspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mspace</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">' '</span>
|
|
748
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
|
749
|
+
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>.<span class="ruby-identifier">nil?</span>
|
|
750
|
+
<span class="ruby-identifier">code</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">lspace</span>)
|
|
751
|
+
<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rspace</span>
|
|
752
|
+
<span class="ruby-comment cmt">#add_stmt(code)</span>
|
|
753
|
+
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-keyword kw">nil</span>
|
|
754
|
+
<span class="ruby-keyword kw">else</span>
|
|
755
|
+
<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">';'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">code</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\n</span>
|
|
756
|
+
<span class="ruby-comment cmt">#add_stmt(code)</span>
|
|
757
|
+
<span class="ruby-identifier">prev_rspace</span> = <span class="ruby-identifier">rspace</span>
|
|
758
|
+
<span class="ruby-keyword kw">end</span>
|
|
759
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">code</span>
|
|
760
|
+
<span class="ruby-identifier">code</span> = <span class="ruby-identifier">statement_hook</span>(<span class="ruby-identifier">code</span>)
|
|
761
|
+
<span class="ruby-identifier">add_stmt</span>(<span class="ruby-identifier">code</span>)
|
|
762
|
+
<span class="ruby-keyword kw">end</span>
|
|
763
|
+
<span class="ruby-keyword kw">end</span>
|
|
764
|
+
<span class="ruby-comment cmt">#rest = $' || input</span>
|
|
765
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">pos</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">input</span>
|
|
766
|
+
<span class="ruby-identifier">rest</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">prev_rspace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prev_rspace</span>
|
|
767
|
+
<span class="ruby-identifier">parse_exprs</span>(<span class="ruby-identifier">rest</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rest</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rest</span>.<span class="ruby-identifier">empty?</span>
|
|
768
|
+
<span class="ruby-keyword kw">end</span>
|
|
769
|
+
</pre>
|
|
770
|
+
</div>
|
|
771
|
+
</div>
|
|
772
|
+
</div>
|
|
773
|
+
|
|
774
|
+
<div id="method-M000057" class="method-detail">
|
|
775
|
+
<a name="M000057"></a>
|
|
776
|
+
|
|
777
|
+
<div class="method-heading">
|
|
778
|
+
<a href="#M000057" class="method-signature">
|
|
779
|
+
<span class="method-name">start_text_part</span><span class="method-args">()</span>
|
|
780
|
+
</a>
|
|
781
|
+
</div>
|
|
782
|
+
|
|
783
|
+
<div class="method-description">
|
|
784
|
+
<p>
|
|
785
|
+
start text part
|
|
786
|
+
</p>
|
|
787
|
+
<p><a class="source-toggle" href="#"
|
|
788
|
+
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
|
789
|
+
<div class="method-source-code" id="M000057-source">
|
|
790
|
+
<pre>
|
|
791
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 559</span>
|
|
792
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start_text_part</span>()
|
|
793
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << %Q`"</span>
|
|
794
|
+
<span class="ruby-keyword kw">end</span>
|
|
795
|
+
</pre>
|
|
796
|
+
</div>
|
|
797
|
+
</div>
|
|
798
|
+
</div>
|
|
799
|
+
|
|
800
|
+
<div id="method-M000056" class="method-detail">
|
|
801
|
+
<a name="M000056"></a>
|
|
802
|
+
|
|
803
|
+
<div class="method-heading">
|
|
804
|
+
<a href="#M000056" class="method-signature">
|
|
805
|
+
<span class="method-name">statement_hook</span><span class="method-args">(stmt)</span>
|
|
806
|
+
</a>
|
|
807
|
+
</div>
|
|
808
|
+
|
|
809
|
+
<div class="method-description">
|
|
810
|
+
<p>
|
|
811
|
+
expand macros and parse ’#@ARGS’ in a statement.
|
|
812
|
+
</p>
|
|
813
|
+
<p><a class="source-toggle" href="#"
|
|
814
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
|
815
|
+
<div class="method-source-code" id="M000056-source">
|
|
816
|
+
<pre>
|
|
817
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 500</span>
|
|
818
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">statement_hook</span>(<span class="ruby-identifier">stmt</span>)
|
|
819
|
+
<span class="ruby-comment cmt">## macro expantion</span>
|
|
820
|
+
<span class="ruby-comment cmt">#macro_pattern = /\A\s*(\w+)\((.*?)\);?(\s*)\z/</span>
|
|
821
|
+
<span class="ruby-comment cmt">#if macro_pattern =~ stmt</span>
|
|
822
|
+
<span class="ruby-comment cmt"># name = $1; arg = $2; rspace = $3</span>
|
|
823
|
+
<span class="ruby-comment cmt"># handler = get_macro_handler(name)</span>
|
|
824
|
+
<span class="ruby-comment cmt"># ret = handler ? handler.call(arg) + $3 : stmt</span>
|
|
825
|
+
<span class="ruby-comment cmt"># return ret</span>
|
|
826
|
+
<span class="ruby-comment cmt">#end</span>
|
|
827
|
+
<span class="ruby-comment cmt">## arguments declaration</span>
|
|
828
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@args</span>.<span class="ruby-identifier">nil?</span>
|
|
829
|
+
<span class="ruby-identifier">args_pattern</span> = <span class="ruby-regexp re">/\A *\#@ARGS([ \t]+(.*?))?(\s*)\z/</span> <span class="ruby-comment cmt">#</span>
|
|
830
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args_pattern</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">stmt</span>
|
|
831
|
+
<span class="ruby-ivar">@args</span> = []
|
|
832
|
+
<span class="ruby-identifier">declares</span> = <span class="ruby-value str">''</span>
|
|
833
|
+
<span class="ruby-identifier">rspace</span> = <span class="ruby-identifier">$3</span>
|
|
834
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$2</span>
|
|
835
|
+
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>)
|
|
836
|
+
<span class="ruby-identifier">arg</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">strip</span>()
|
|
837
|
+
<span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">empty?</span>
|
|
838
|
+
<span class="ruby-identifier">arg</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[a-zA-Z_]\w*\z/</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{arg}: invalid template argument."</span>)
|
|
839
|
+
<span class="ruby-ivar">@args</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">arg</span>
|
|
840
|
+
<span class="ruby-identifier">declares</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" #{arg} = @#{arg};"</span>
|
|
841
|
+
<span class="ruby-keyword kw">end</span>
|
|
842
|
+
<span class="ruby-keyword kw">end</span>
|
|
843
|
+
<span class="ruby-identifier">declares</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">rspace</span>
|
|
844
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">declares</span>
|
|
845
|
+
<span class="ruby-keyword kw">end</span>
|
|
846
|
+
<span class="ruby-keyword kw">end</span>
|
|
847
|
+
<span class="ruby-comment cmt">##</span>
|
|
848
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">stmt</span>
|
|
849
|
+
<span class="ruby-keyword kw">end</span>
|
|
850
|
+
</pre>
|
|
851
|
+
</div>
|
|
852
|
+
</div>
|
|
853
|
+
</div>
|
|
854
|
+
|
|
855
|
+
<div id="method-M000051" class="method-detail">
|
|
856
|
+
<a name="M000051"></a>
|
|
857
|
+
|
|
858
|
+
<div class="method-heading">
|
|
859
|
+
<a href="#M000051" class="method-signature">
|
|
860
|
+
<span class="method-name">stmt_pattern</span><span class="method-args">()</span>
|
|
861
|
+
</a>
|
|
862
|
+
</div>
|
|
863
|
+
|
|
864
|
+
<div class="method-description">
|
|
865
|
+
<p><a class="source-toggle" href="#"
|
|
866
|
+
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
|
867
|
+
<div class="method-source-code" id="M000051-source">
|
|
868
|
+
<pre>
|
|
869
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 387</span>
|
|
870
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stmt_pattern</span>
|
|
871
|
+
<span class="ruby-constant">STMT_PATTERN</span>
|
|
872
|
+
<span class="ruby-keyword kw">end</span>
|
|
873
|
+
</pre>
|
|
874
|
+
</div>
|
|
875
|
+
</div>
|
|
876
|
+
</div>
|
|
877
|
+
|
|
878
|
+
<div id="method-M000058" class="method-detail">
|
|
879
|
+
<a name="M000058"></a>
|
|
880
|
+
|
|
881
|
+
<div class="method-heading">
|
|
882
|
+
<a href="#M000058" class="method-signature">
|
|
883
|
+
<span class="method-name">stop_text_part</span><span class="method-args">()</span>
|
|
884
|
+
</a>
|
|
885
|
+
</div>
|
|
886
|
+
|
|
887
|
+
<div class="method-description">
|
|
888
|
+
<p>
|
|
889
|
+
stop text part
|
|
890
|
+
</p>
|
|
891
|
+
<p><a class="source-toggle" href="#"
|
|
892
|
+
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
|
893
|
+
<div class="method-source-code" id="M000058-source">
|
|
894
|
+
<pre>
|
|
895
|
+
<span class="ruby-comment cmt"># File lib/tenjin.rb, line 564</span>
|
|
896
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop_text_part</span>()
|
|
897
|
+
<span class="ruby-ivar">@script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'`'</span>
|
|
898
|
+
<span class="ruby-keyword kw">end</span>
|
|
899
|
+
</pre>
|
|
900
|
+
</div>
|
|
901
|
+
</div>
|
|
902
|
+
</div>
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
</div>
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
</div>
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
<div id="validator-badges">
|
|
912
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
913
|
+
</div>
|
|
914
|
+
|
|
915
|
+
</body>
|
|
916
|
+
</html>
|