erbook 5.0.0 → 6.0.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.
Files changed (68) hide show
  1. data/LICENSE +1 -1
  2. data/Rakefile +6 -79
  3. data/bin/erbook +25 -319
  4. data/doc/HelloWorld.spec +23 -21
  5. data/doc/README +4 -3
  6. data/doc/api/ERBook.html +35 -0
  7. data/doc/api/ERBook/Document.html +673 -0
  8. data/doc/api/ERBook/Document/Node.html +102 -0
  9. data/doc/api/ERBook/Template.html +670 -0
  10. data/doc/api/RDoc.html +23 -0
  11. data/doc/api/RDoc/AnyMethod.html +302 -0
  12. data/doc/api/RDoc/DummyMarkup.html +73 -0
  13. data/doc/api/RDoc/DummyMixin.html +23 -0
  14. data/doc/api/RDoc/DummyOptions.html +140 -0
  15. data/doc/api/RDoc/TopLevel.html +465 -0
  16. data/doc/api/String.html +372 -0
  17. data/doc/api/all-methods.html +253 -0
  18. data/doc/api/all-namespaces.html +42 -0
  19. data/doc/api/app.js +18 -0
  20. data/doc/api/index.html +16 -22
  21. data/doc/api/jquery.js +11 -0
  22. data/doc/api/readme.html +35 -0
  23. data/doc/api/style.css +68 -0
  24. data/doc/api/syntax_highlight.css +21 -0
  25. data/doc/erbook.png +0 -0
  26. data/doc/erbook.svg +150 -88
  27. data/doc/formats.erb +387 -0
  28. data/doc/history.erb +62 -0
  29. data/doc/index.erb +8 -0
  30. data/doc/index.xhtml +846 -654
  31. data/doc/intro.erb +97 -0
  32. data/doc/setup.erb +62 -0
  33. data/doc/theory.erb +187 -0
  34. data/doc/usage.erb +39 -0
  35. data/fmt/xhtml.yaml +497 -372
  36. data/lib/erbook.rb +18 -10
  37. data/lib/erbook/document.rb +233 -0
  38. data/lib/erbook/template.rb +210 -0
  39. data/lib/erbook/to_xhtml.rb +25 -17
  40. metadata +39 -45
  41. data/README +0 -14
  42. data/doc/api/classes/ERBook.html +0 -164
  43. data/doc/api/classes/RDoc.html +0 -112
  44. data/doc/api/classes/RDoc/AnyMethod.html +0 -195
  45. data/doc/api/classes/RDoc/AnyMethod.src/M000003.html +0 -18
  46. data/doc/api/classes/RDoc/AnyMethod.src/M000004.html +0 -23
  47. data/doc/api/classes/RDoc/AnyMethod.src/M000005.html +0 -18
  48. data/doc/api/classes/RDoc/AnyMethod.src/M000006.html +0 -22
  49. data/doc/api/classes/RDoc/TopLevel.html +0 -250
  50. data/doc/api/classes/RDoc/TopLevel.src/M000007.html +0 -18
  51. data/doc/api/classes/RDoc/TopLevel.src/M000008.html +0 -18
  52. data/doc/api/classes/RDoc/TopLevel.src/M000009.html +0 -18
  53. data/doc/api/classes/RDoc/TopLevel.src/M000010.html +0 -29
  54. data/doc/api/classes/RDoc/TopLevel.src/M000011.html +0 -25
  55. data/doc/api/classes/RDoc/TopLevel.src/M000012.html +0 -18
  56. data/doc/api/classes/String.html +0 -196
  57. data/doc/api/classes/String.src/M000001.html +0 -18
  58. data/doc/api/classes/String.src/M000002.html +0 -31
  59. data/doc/api/created.rid +0 -1
  60. data/doc/api/files/lib/erbook/rdoc_rb.html +0 -116
  61. data/doc/api/files/lib/erbook/to_xhtml_rb.html +0 -125
  62. data/doc/api/files/lib/erbook_rb.html +0 -107
  63. data/doc/api/fr_class_index.html +0 -31
  64. data/doc/api/fr_file_index.html +0 -29
  65. data/doc/api/fr_method_index.html +0 -38
  66. data/doc/api/rdoc-style.css +0 -208
  67. data/doc/feed-icon-28x28.png +0 -0
  68. data/doc/manual.erb +0 -812
@@ -0,0 +1,102 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="../../style.css" type="text/css" charset="utf-8" />
7
+ <link rel="stylesheet" href="../../syntax_highlight.css" type="text/css" charset="utf-8" />
8
+
9
+ <script src="../../jquery.js" type="text/javascript" charset="utf-8"></script>
10
+ <script src="../../app.js" type="text/javascript" charset="utf-8"></script>
11
+ <title>Class: ERBook::Document::Node</title>
12
+ </head>
13
+ <body>
14
+ <div id="content">
15
+ <div class="section class ERBook_Document_Node">
16
+ <h1 class="title">Class: ERBook::Document::Node</h1>
17
+ <div class="section inheritance">
18
+ <ul>
19
+ <li>OpenStruct</li><ul><li>ERBook::Document::Node</li>
20
+ </ul></ul>
21
+ </div><div class="section constants">
22
+
23
+ </div> <div class="section visibilitygroup public">
24
+ <h1>Public Visibility</h1>
25
+ <div class="section methodsummary instance public">
26
+ <h1>Public Instance Method Summary</h1>
27
+ <table class="summary">
28
+
29
+ <tr>
30
+ <th class="signature">
31
+ <span class='name'><a href="#to_s-instance_method" title="#to_s">#to_s</a></span><span class='args'></span>
32
+ <span class='block'></span>
33
+
34
+ </th>
35
+ <td class="docstring">
36
+ <p>
37
+ Returns the output of this node.
38
+ </p>
39
+
40
+
41
+ </td>
42
+ </tr>
43
+
44
+ </table>
45
+ </div>
46
+ <div class="section methoddetails instance public">
47
+ <h1>Public Instance Method Details</h1>
48
+
49
+ <div class="method">
50
+ <div class="method_header">
51
+ <h3>to_s</h3>
52
+ </div><div id="to_s-instance_method" class="section method">
53
+ <div class="details_title">
54
+ <div class='section methodsignature'>
55
+ <tt class='def'>
56
+ <span class='visibility'>public</span>
57
+ <span class='return_types'></span>
58
+ <span class='name'>to_s</span><span class='args'></span>
59
+ <span class='block'></span>
60
+ </tt>
61
+ </div>
62
+
63
+ </div><div class="section docstring">
64
+ <p>
65
+ Returns the output of this node.
66
+ </p>
67
+
68
+ </div><div class="section source">
69
+ <span>[<a class="source_link" href="#">View source</a>]</span>
70
+ <div class="source_code">
71
+ <table>
72
+ <tr>
73
+ <td>
74
+ <pre class="lines">
75
+
76
+
77
+ 205
78
+ 206
79
+ 207</pre>
80
+ </td>
81
+ <td>
82
+ <pre class="code"><span class="info file"># File 'lib/erbook/document.rb', line 205</span>
83
+
84
+ <span class='def def kw'>def</span> <span class='to_s identifier id'>to_s</span>
85
+ <span class='output identifier id'>output</span>
86
+ <span class='end end kw'>end</span>
87
+ </pre>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+ </div>
98
+
99
+ </div>
100
+ </div>
101
+ </body>
102
+ </html>
@@ -0,0 +1,670 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="../style.css" type="text/css" charset="utf-8" />
7
+ <link rel="stylesheet" href="../syntax_highlight.css" type="text/css" charset="utf-8" />
8
+
9
+ <script src="../jquery.js" type="text/javascript" charset="utf-8"></script>
10
+ <script src="../app.js" type="text/javascript" charset="utf-8"></script>
11
+ <title>Class: ERBook::Template</title>
12
+ </head>
13
+ <body>
14
+ <div id="content">
15
+ <div class="section class ERBook_Template">
16
+ <h1 class="title">Class: ERBook::Template</h1>
17
+ <div class="section inheritance">
18
+ <ul>
19
+ <li>ERB</li><ul><li>ERBook::Template</li>
20
+ </ul></ul>
21
+ </div><div class="section docstring">
22
+ <p>
23
+ An eRuby template which allows access to the underlying result buffer
24
+ (which contains the result of template evaluation thus far) and provides
25
+ sandboxing for isolated template rendering.
26
+ </p>
27
+ <p>
28
+ In addition to the standard &lt;% eRuby %&gt; directives, this template
29
+ supports:
30
+ </p>
31
+ <ul>
32
+ <li>Lines that begin with &#8217;%&#8217; are treated as normal eRuby
33
+ directives.
34
+
35
+ </li>
36
+ <li>Include directives (&lt;%#include YOUR_PATH #%&gt;) are replaced by the
37
+ result of reading and evaluating the YOUR_PATH file in the current context.
38
+
39
+ <ul>
40
+ <li>Unless YOUR_PATH is an absolute path, it is treated as being relative to
41
+ the file which contains the include directive.
42
+
43
+ </li>
44
+ <li>Errors originating from included files are given a proper stack trace which
45
+ shows the chain of inclusion plus any further trace steps originating from
46
+ the included file itself.
47
+
48
+ </li>
49
+ </ul>
50
+ </li>
51
+ <li>eRuby directives delimiting Ruby blocks (&lt;% &#8230; do %&gt; &#8230;
52
+ &lt;% end %&gt;) can be heirarchically unindented by the crown margin of
53
+ the opening (&lt;% &#8230; do %&gt;) delimiter.
54
+
55
+ </li>
56
+ </ul>
57
+
58
+ </div><div class="section attributes">
59
+ <h1>Attributes</h1>
60
+
61
+
62
+ <div class="instance">
63
+ <h2>Instance Attributes</h2>
64
+ <table>
65
+
66
+ <tr>
67
+ <th class="name">buffer</td>
68
+ <td class="readwrite">
69
+ [<span id='buffer-instance_method'>R</span>W]
70
+ </td>
71
+ <td class="visibility">
72
+ public
73
+ </td>
74
+ <td class="docstring">
75
+ <p>
76
+ The result of template evaluation thus far.
77
+ </p>
78
+
79
+
80
+ </td>
81
+ </tr>
82
+
83
+ </table>
84
+ </div>
85
+
86
+ </div><div class="section constants">
87
+
88
+ </div><div class="section constructor">
89
+ <h1>Constructor Summary</h1>
90
+ <div id="initialize-instance_method" class="section method">
91
+ <div class="details_title">
92
+ <div class='section methodsignature'>
93
+ <tt class='def'>
94
+ <span class='visibility'>public</span>
95
+ <span class='return_types'></span>
96
+ <span class='name'>initialize</span><span class='args'>(source, input, unindent = false, safe_level = nil)</span>
97
+ <span class='block'></span>
98
+ </tt>
99
+ </div>
100
+
101
+ </div><div class="section tags">
102
+ <h2>Meta Tags</h2>
103
+ <div class="param">
104
+ <h3>Parameters:</h3>
105
+ <dl>
106
+
107
+
108
+ <dt>
109
+ <span class='type'>[<tt><a href="../String.html" title="String">String</a></tt>]</span>
110
+ <span class='name'>source</span>
111
+
112
+ </dt>
113
+ <dd>
114
+ <span class='desc'><p>
115
+ Replacement for the ambiguous &#8217;(erb)&#8217; identifier in stack
116
+ traces; so that the user can better determine the source of an error.
117
+ </p>
118
+ </span>
119
+ </dd>
120
+
121
+
122
+
123
+ <dt>
124
+ <span class='type'>[<tt><a href="../String.html" title="String">String</a></tt>]</span>
125
+ <span class='name'>input</span>
126
+
127
+ </dt>
128
+ <dd>
129
+ <span class='desc'><p>
130
+ A string containing eRuby directives.
131
+ </p>
132
+ </span>
133
+ </dd>
134
+
135
+
136
+
137
+ <dt>
138
+ <span class='type'>[<tt>boolean</tt>]</span>
139
+ <span class='name'>unindent</span>
140
+
141
+ <em class="default">(defaults to: <tt>false</tt>)</em>
142
+
143
+ </dt>
144
+ <dd>
145
+ <span class='desc'><p>
146
+ If true, then all content blocks will be unindented hierarchically, by the
147
+ leading space of their &#8216;do&#8217; and &#8216;end&#8217; delimiters.
148
+ </p>
149
+ </span>
150
+ </dd>
151
+
152
+
153
+
154
+ <dt>
155
+ <span class='type'>[<tt>Object</tt>]</span>
156
+ <span class='name'>safe_level</span>
157
+
158
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
159
+
160
+ </dt>
161
+ <dd>
162
+ <span class='desc'><p>
163
+ See safe_level in ERB::new().
164
+ </p>
165
+ </span>
166
+ </dd>
167
+
168
+
169
+ </dl>
170
+ </div>
171
+ </div><div class="section source">
172
+ <span>[<a class="source_link" href="#">View source</a>]</span>
173
+ <div class="source_code">
174
+ <table>
175
+ <tr>
176
+ <td>
177
+ <pre class="lines">
178
+
179
+
180
+ 47
181
+ 48
182
+ 49
183
+ 50
184
+ 51
185
+ 52
186
+ 53
187
+ 54
188
+ 55
189
+ 56
190
+ 57
191
+ 58
192
+ 59
193
+ 60
194
+ 61
195
+ 62
196
+ 63
197
+ 64
198
+ 65
199
+ 66
200
+ 67
201
+ 68
202
+ 69
203
+ 70
204
+ 71
205
+ 72
206
+ 73
207
+ 74
208
+ 75
209
+ 76
210
+ 77
211
+ 78
212
+ 79
213
+ 80
214
+ 81
215
+ 82
216
+ 83
217
+ 84
218
+ 85
219
+ 86
220
+ 87
221
+ 88
222
+ 89
223
+ 90
224
+ 91
225
+ 92
226
+ 93
227
+ 94
228
+ 95
229
+ 96
230
+ 97
231
+ 98
232
+ 99
233
+ 100
234
+ 101
235
+ 102
236
+ 103
237
+ 104
238
+ 105
239
+ 106
240
+ 107
241
+ 108
242
+ 109
243
+ 110
244
+ 111
245
+ 112
246
+ 113
247
+ 114
248
+ 115
249
+ 116
250
+ 117
251
+ 118
252
+ 119
253
+ 120
254
+ 121
255
+ 122
256
+ 123
257
+ 124
258
+ 125
259
+ 126
260
+ 127
261
+ 128
262
+ 129
263
+ 130
264
+ 131
265
+ 132
266
+ 133
267
+ 134
268
+ 135
269
+ 136
270
+ 137
271
+ 138
272
+ 139
273
+ 140
274
+ 141
275
+ 142
276
+ 143
277
+ 144
278
+ 145
279
+ 146
280
+ 147
281
+ 148
282
+ 149
283
+ 150
284
+ 151
285
+ 152
286
+ 153
287
+ 154
288
+ 155
289
+ 156
290
+ 157
291
+ 158
292
+ 159
293
+ 160
294
+ 161
295
+ 162
296
+ 163
297
+ 164
298
+ 165
299
+ 166
300
+ 167
301
+ 168
302
+ 169
303
+ 170
304
+ 171
305
+ 172
306
+ 173
307
+ 174
308
+ 175</pre>
309
+ </td>
310
+ <td>
311
+ <pre class="code"><span class="info file"># File 'lib/erbook/template.rb', line 47</span>
312
+
313
+ <span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span> <span class='source identifier id'>source</span><span class='comma token'>,</span> <span class='input identifier id'>input</span><span class='comma token'>,</span> <span class='unindent identifier id'>unindent</span> <span class='assign token'>=</span> <span class='false false kw'>false</span><span class='comma token'>,</span> <span class='safe_level identifier id'>safe_level</span> <span class='assign token'>=</span> <span class='nil nil kw'>nil</span>
314
+ <span class='comment val'># expand all &quot;include&quot; directives in the input</span>
315
+ <span class='expander identifier id'>expander</span> <span class='assign token'>=</span> <span class='lambda identifier id'>lambda</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='src_file identifier id'>src_file</span><span class='comma token'>,</span> <span class='src_text identifier id'>src_text</span><span class='comma token'>,</span> <span class='path_stack identifier id'>path_stack</span><span class='comma token'>,</span> <span class='stack_trace identifier id'>stack_trace</span><span class='bitor op'>|</span>
316
+ <span class='src_path identifier id'>src_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='expand_path identifier id'>expand_path</span><span class='lparen token'>(</span><span class='src_file identifier id'>src_file</span><span class='rparen token'>)</span>
317
+ <span class='src_line identifier id'>src_line</span> <span class='assign token'>=</span> <span class='integer val'>1</span> <span class='comment val'># line number of the current include directive in src_file</span>
318
+
319
+ <span class='chunks identifier id'>chunks</span> <span class='assign token'>=</span> <span class='src_text identifier id'>src_text</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='regexp val'>/&lt;%#\s*include\s+(.+?)\s*#%&gt;/</span><span class='rparen token'>)</span>
320
+
321
+ <span class='path_stack identifier id'>path_stack</span><span class='dot token'>.</span><span class='push identifier id'>push</span> <span class='src_path identifier id'>src_path</span>
322
+ <span class='chunks identifier id'>chunks</span><span class='dot token'>.</span><span class='each_with_index identifier id'>each_with_index</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='chunk identifier id'>chunk</span><span class='comma token'>,</span> <span class='i identifier id'>i</span><span class='bitor op'>|</span>
323
+ <span class='comment val'># even number: chunk is not an include directive</span>
324
+ <span class='if if kw'>if</span> <span class='i identifier id'>i</span> <span class='bitand op'>&amp;</span> <span class='integer val'>1</span> <span class='eq op'>==</span> <span class='integer val'>0</span>
325
+ <span class='src_line identifier id'>src_line</span> <span class='opasgn op'>+=</span> <span class='chunk identifier id'>chunk</span><span class='dot token'>.</span><span class='count identifier id'>count</span><span class='lparen token'>(</span><span class='string val'>&quot;\n&quot;</span><span class='rparen token'>)</span>
326
+
327
+ <span class='comment val'># odd number: chunk is the target of the include directive</span>
328
+ <span class='else else kw'>else</span>
329
+ <span class='comment val'># resolve correct path of target file</span>
330
+ <span class='dst_file identifier id'>dst_file</span> <span class='assign token'>=</span> <span class='chunk identifier id'>chunk</span>
331
+
332
+ <span class='unless unless kw'>unless</span> <span class='Pathname constant id'>Pathname</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='dst_file identifier id'>dst_file</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='absolute? fid id'>absolute?</span>
333
+ <span class='comment val'># target is relative to the file in</span>
334
+ <span class='comment val'># which the include directive exists</span>
335
+ <span class='dst_file identifier id'>dst_file</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='join identifier id'>join</span><span class='lparen token'>(</span><span class='File constant id'>File</span><span class='dot token'>.</span><span class='dirname identifier id'>dirname</span><span class='lparen token'>(</span><span class='src_file identifier id'>src_file</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='dst_file identifier id'>dst_file</span><span class='rparen token'>)</span>
336
+ <span class='end end kw'>end</span>
337
+
338
+ <span class='dst_path identifier id'>dst_path</span> <span class='assign token'>=</span> <span class='File constant id'>File</span><span class='dot token'>.</span><span class='expand_path identifier id'>expand_path</span><span class='lparen token'>(</span><span class='dst_file identifier id'>dst_file</span><span class='rparen token'>)</span>
339
+
340
+ <span class='comment val'># include the target file</span>
341
+ <span class='if if kw'>if</span> <span class='path_stack identifier id'>path_stack</span><span class='dot token'>.</span><span class='include? fid id'>include?</span> <span class='dst_file identifier id'>dst_file</span>
342
+ <span class='raise identifier id'>raise</span> <span class='dstring node'>&quot;Cannot include #{dst_file.inspect} at #{src_file.inspect}:#{src_line} because that would cause an infinite loop in the inclusion stack: #{path_stack.inspect}.&quot;</span>
343
+ <span class='else else kw'>else</span>
344
+ <span class='stack_trace identifier id'>stack_trace</span><span class='dot token'>.</span><span class='push identifier id'>push</span> <span class='dstring node'>&quot;#{src_path}:#{src_line}&quot;</span>
345
+ <span class='dst_text identifier id'>dst_text</span> <span class='assign token'>=</span> <span class='eval identifier id'>eval</span><span class='lparen token'>(</span><span class='string val'>'File.read dst_file'</span><span class='comma token'>,</span> <span class='binding identifier id'>binding</span><span class='comma token'>,</span> <span class='src_file identifier id'>src_file</span><span class='comma token'>,</span> <span class='src_line identifier id'>src_line</span><span class='rparen token'>)</span>
346
+
347
+ <span class='comment val'># recursively expand any include directives within</span>
348
+ <span class='comment val'># the expansion of the current include directive</span>
349
+ <span class='dst_text identifier id'>dst_text</span> <span class='assign token'>=</span> <span class='expander identifier id'>expander</span><span class='lbrack token'>[</span><span class='dst_file identifier id'>dst_file</span><span class='comma token'>,</span> <span class='dst_text identifier id'>dst_text</span><span class='comma token'>,</span> <span class='path_stack identifier id'>path_stack</span><span class='comma token'>,</span> <span class='stack_trace identifier id'>stack_trace</span><span class='rbrack token'>]</span>
350
+
351
+ <span class='comment val'># provide more accurate stack trace for</span>
352
+ <span class='comment val'># errors originating from included files</span>
353
+ <span class='line_var identifier id'>line_var</span> <span class='assign token'>=</span> <span class='dstring node'>&quot;__erbook_var_#{dst_file.object_id.abs}__&quot;</span>
354
+ <span class='dst_text identifier id'>dst_text</span> <span class='assign token'>=</span> <span class='dstring node'>%{&lt;%
355
+ #{line_var} = __LINE__ + 2 # content is 2 newlines below
356
+ begin
357
+ %&gt;#{dst_text}&lt;%
358
+ rescue Exception =&gt; err
359
+ bak = err.backtrace
360
+
361
+ top = []
362
+ found_top = false
363
+ prev_line = nil
364
+
365
+ bak.each do |step|
366
+ if step =~ /^#{/#{source}/}:(\\d+)(.*)/
367
+ line, desc = $1, $2
368
+ line = line.to_i - #{line_var} + 1
369
+
370
+ if line &gt; 0 and line != prev_line
371
+ top &lt;&lt; &quot;#{dst_path}:\#{line}\#{desc}&quot;
372
+ found_top = true
373
+ prev_line = line
374
+ end
375
+ elsif !found_top
376
+ top &lt;&lt; step
377
+ end
378
+ end
379
+
380
+ if found_top
381
+ bak.replace top
382
+ bak.concat #{stack_trace.reverse.inspect}
383
+ end
384
+
385
+ raise err
386
+ end
387
+ %&gt;}</span>
388
+
389
+ <span class='stack_trace identifier id'>stack_trace</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span>
390
+ <span class='end end kw'>end</span>
391
+
392
+ <span class='chunks identifier id'>chunks</span><span class='lbrack token'>[</span><span class='i identifier id'>i</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='dst_text identifier id'>dst_text</span>
393
+ <span class='end end kw'>end</span>
394
+ <span class='end end kw'>end</span>
395
+ <span class='path_stack identifier id'>path_stack</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span>
396
+
397
+ <span class='chunks identifier id'>chunks</span><span class='dot token'>.</span><span class='join identifier id'>join</span>
398
+ <span class='end end kw'>end</span>
399
+
400
+ <span class='input identifier id'>input</span> <span class='assign token'>=</span> <span class='expander identifier id'>expander</span><span class='lbrack token'>[</span><span class='source identifier id'>source</span><span class='comma token'>,</span> <span class='input identifier id'>input</span><span class='comma token'>,</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
401
+
402
+ <span class='comment val'># convert &quot;% at beginning of line&quot; usage into &lt;% normal %&gt; usage</span>
403
+ <span class='input identifier id'>input</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{^([ \t]*)(%[=# \t].*)$}</span><span class='comma token'>,</span> <span class='string val'>'\1&lt;\2 %&gt;'</span>
404
+ <span class='input identifier id'>input</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{^([ \t]*)%%}</span><span class='comma token'>,</span> <span class='string val'>'\1%'</span>
405
+
406
+ <span class='comment val'># unindent node content hierarchically</span>
407
+ <span class='if if kw'>if</span> <span class='unindent identifier id'>unindent</span>
408
+ <span class='tags identifier id'>tags</span> <span class='assign token'>=</span> <span class='input identifier id'>input</span><span class='dot token'>.</span><span class='scan identifier id'>scan</span><span class='lparen token'>(</span><span class='regexp val'>/&lt;%(?:.(?!&lt;%))*?%&gt;/</span><span class='m identifier id'>m</span><span class='rparen token'>)</span>
409
+ <span class='margins identifier id'>margins</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
410
+ <span class='result identifier id'>result</span> <span class='assign token'>=</span> <span class='lbrack token'>[</span><span class='rbrack token'>]</span>
411
+
412
+ <span class='buffer identifier id'>buffer</span> <span class='assign token'>=</span> <span class='input identifier id'>input</span>
413
+ <span class='tags identifier id'>tags</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='tag identifier id'>tag</span><span class='bitor op'>|</span>
414
+ <span class='chunk identifier id'>chunk</span><span class='comma token'>,</span> <span class='buffer identifier id'>buffer</span> <span class='assign token'>=</span> <span class='buffer identifier id'>buffer</span><span class='dot token'>.</span><span class='split identifier id'>split</span><span class='lparen token'>(</span><span class='tag identifier id'>tag</span><span class='comma token'>,</span> <span class='integer val'>2</span><span class='rparen token'>)</span>
415
+ <span class='chunk identifier id'>chunk</span> <span class='lshft op'>&lt;&lt;</span> <span class='tag identifier id'>tag</span>
416
+
417
+ <span class='comment val'># perform unindentation</span>
418
+ <span class='result identifier id'>result</span> <span class='lshft op'>&lt;&lt;</span> <span class='chunk identifier id'>chunk</span><span class='dot token'>.</span><span class='gsub identifier id'>gsub</span><span class='lparen token'>(</span><span class='dregexp node'>/^#{margins.last}/</span><span class='comma token'>,</span> <span class='string val'>''</span><span class='rparen token'>)</span>
419
+
420
+ <span class='comment val'># prepare for next unindentation</span>
421
+ <span class='case case kw'>case</span> <span class='tag identifier id'>tag</span>
422
+ <span class='when when kw'>when</span> <span class='regexp val'>/&lt;%[^%=].*?\bdo\b.*?%&gt;/</span><span class='m identifier id'>m</span>
423
+ <span class='margins identifier id'>margins</span><span class='dot token'>.</span><span class='push identifier id'>push</span> <span class='buffer identifier id'>buffer</span><span class='lbrack token'>[</span><span class='regexp val'>/^[ \t]*(?=\S)/</span><span class='rbrack token'>]</span>
424
+
425
+ <span class='when when kw'>when</span> <span class='regexp val'>/&lt;%\s*end\s*%&gt;/</span><span class='m identifier id'>m</span>
426
+ <span class='margins identifier id'>margins</span><span class='dot token'>.</span><span class='pop identifier id'>pop</span>
427
+ <span class='end end kw'>end</span>
428
+ <span class='end end kw'>end</span>
429
+ <span class='result identifier id'>result</span> <span class='lshft op'>&lt;&lt;</span> <span class='buffer identifier id'>buffer</span>
430
+
431
+ <span class='input identifier id'>input</span> <span class='assign token'>=</span> <span class='result identifier id'>result</span><span class='dot token'>.</span><span class='join identifier id'>join</span>
432
+ <span class='end end kw'>end</span>
433
+
434
+ <span class='comment val'># silence the code-only &lt;% ... %&gt; directive, just like PHP does</span>
435
+ <span class='input identifier id'>input</span><span class='dot token'>.</span><span class='gsub! fid id'>gsub!</span> <span class='regexp val'>%r{^[ \t]*(&lt;%[^%=]((?!&lt;%).)*?[^%]%&gt;)[ \t]*\r?\n}</span><span class='m identifier id'>m</span><span class='comma token'>,</span> <span class='string val'>'\1'</span>
436
+
437
+ <span class='comment val'># use @buffer to store the result of the ERB template</span>
438
+ <span class='super super kw'>super</span> <span class='input identifier id'>input</span><span class='comma token'>,</span> <span class='safe_level identifier id'>safe_level</span><span class='comma token'>,</span> <span class='nil nil kw'>nil</span><span class='comma token'>,</span> <span class='symbol val'>:@buffer</span>
439
+
440
+ <span class='self self kw'>self</span><span class='dot token'>.</span><span class='filename identifier id'>filename</span> <span class='assign token'>=</span> <span class='source identifier id'>source</span>
441
+ <span class='end end kw'>end</span>
442
+ </pre>
443
+ </td>
444
+ </tr>
445
+ </table>
446
+ </div>
447
+ </div>
448
+ </div>
449
+ </div> <div class="section visibilitygroup public">
450
+ <h1>Public Visibility</h1>
451
+ <div class="section methodsummary instance public">
452
+ <h1>Public Instance Method Summary</h1>
453
+ <table class="summary">
454
+
455
+ <tr>
456
+ <th class="signature">
457
+ <span class='name'><a href="#render_with-instance_method" title="#render_with">#render_with</a></span><span class='args'>(inst_vars = )</span>
458
+ <span class='block'></span>
459
+
460
+ </th>
461
+ <td class="docstring">
462
+ <p>
463
+ Renders this template within a fresh object that is populated with the
464
+ given instance variables, whose names must be prefixed with
465
+ &#8217;@&#8217;.
466
+ </p>
467
+
468
+
469
+ </td>
470
+ </tr>
471
+
472
+ </table>
473
+ </div>
474
+ <div class="section methoddetails instance public">
475
+ <h1>Public Instance Method Details</h1>
476
+
477
+ <div class="method">
478
+ <div class="method_header">
479
+ <h3>render_with</h3>
480
+ </div><div id="render_with-instance_method" class="section method">
481
+ <div class="details_title">
482
+ <div class='section methodsignature'>
483
+ <tt class='def'>
484
+ <span class='visibility'>public</span>
485
+ <span class='return_types'></span>
486
+ <span class='name'>render_with</span><span class='args'>(inst_vars = )</span>
487
+ <span class='block'></span>
488
+ </tt>
489
+ </div>
490
+
491
+ </div><div class="section docstring">
492
+ <p>
493
+ Renders this template within a fresh object that is populated with the
494
+ given instance variables, whose names must be prefixed with
495
+ &#8217;@&#8217;.
496
+ </p>
497
+
498
+ </div><div class="section source">
499
+ <span>[<a class="source_link" href="#">View source</a>]</span>
500
+ <div class="source_code">
501
+ <table>
502
+ <tr>
503
+ <td>
504
+ <pre class="lines">
505
+
506
+
507
+ 179
508
+ 180
509
+ 181
510
+ 182
511
+ 183
512
+ 184
513
+ 185
514
+ 186
515
+ 187
516
+ 188
517
+ 189</pre>
518
+ </td>
519
+ <td>
520
+ <pre class="code"><span class="info file"># File 'lib/erbook/template.rb', line 179</span>
521
+
522
+ <span class='def def kw'>def</span> <span class='render_with identifier id'>render_with</span> <span class='inst_vars identifier id'>inst_vars</span> <span class='assign token'>=</span> <span class='semicolon token'>;</span><span class='lbrace token'>{</span><span class='rbrace token'>}</span>
523
+ <span class='context identifier id'>context</span> <span class='assign token'>=</span> <span class='Object constant id'>Object</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='dot token'>.</span><span class='instance_eval identifier id'>instance_eval</span> <span class='do do kw'>do</span>
524
+ <span class='inst_vars identifier id'>inst_vars</span><span class='dot token'>.</span><span class='each_pair identifier id'>each_pair</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='var identifier id'>var</span><span class='comma token'>,</span> <span class='val identifier id'>val</span><span class='bitor op'>|</span>
525
+ <span class='instance_variable_set identifier id'>instance_variable_set</span> <span class='var identifier id'>var</span><span class='comma token'>,</span> <span class='val identifier id'>val</span>
526
+ <span class='end end kw'>end</span>
527
+
528
+ <span class='binding identifier id'>binding</span>
529
+ <span class='end end kw'>end</span>
530
+
531
+ <span class='result identifier id'>result</span> <span class='context identifier id'>context</span>
532
+ <span class='end end kw'>end</span>
533
+ </pre>
534
+ </td>
535
+ </tr>
536
+ </table>
537
+ </div>
538
+ </div>
539
+ </div>
540
+ </div>
541
+
542
+ </div>
543
+ </div>
544
+ <div class="section visibilitygroup protected">
545
+ <h1>Protected Visibility</h1>
546
+ <div class="section methodsummary instance protected">
547
+ <h1>Protected Instance Method Summary</h1>
548
+ <table class="summary">
549
+
550
+ <tr>
551
+ <th class="signature">
552
+ <span class='name'><a href="#content_from_block-instance_method" title="#content_from_block">#content_from_block</a></span><span class='args'>(*block_args)</span>
553
+ <span class='block'></span>
554
+
555
+ </th>
556
+ <td class="docstring">
557
+ <p>
558
+ Returns the content that the given block wants to append to the buffer.
559
+ </p>
560
+
561
+
562
+ </td>
563
+ </tr>
564
+
565
+ </table>
566
+ </div>
567
+ <div class="section methoddetails instance protected">
568
+ <h1>Protected Instance Method Details</h1>
569
+
570
+ <div class="method">
571
+ <div class="method_header">
572
+ <h3>content_from_block</h3>
573
+ </div><div id="content_from_block-instance_method" class="section method">
574
+ <div class="details_title">
575
+ <div class='section methodsignature'>
576
+ <tt class='def'>
577
+ <span class='visibility'>protected</span>
578
+ <span class='return_types'></span>
579
+ <span class='name'>content_from_block</span><span class='args'>(*block_args)</span>
580
+ <span class='block'></span>
581
+ </tt>
582
+ </div>
583
+
584
+ </div><div class="section docstring">
585
+ <p>
586
+ Returns the content that the given block wants to append to the buffer. If
587
+ the given block does not want to append to the buffer, then returns the
588
+ result of invoking the given block.
589
+ </p>
590
+
591
+ </div><div class="section tags">
592
+ <h2>Meta Tags</h2>
593
+ <div class="param">
594
+ <h3>Parameters:</h3>
595
+ <dl>
596
+
597
+ </dl>
598
+ </div><div class="raise">
599
+ <h3>Raises:</h3>
600
+ <dl>
601
+
602
+ <dt>
603
+
604
+ <span class='type'>[<tt>ArgumentError</tt>]</span>
605
+
606
+
607
+
608
+ </dt>
609
+ <dd>
610
+ <span class='desc'></span>
611
+ </dd>
612
+
613
+ </dl>
614
+ </div>
615
+
616
+ </div><div class="section source">
617
+ <span>[<a class="source_link" href="#">View source</a>]</span>
618
+ <div class="source_code">
619
+ <table>
620
+ <tr>
621
+ <td>
622
+ <pre class="lines">
623
+
624
+
625
+ 196
626
+ 197
627
+ 198
628
+ 199
629
+ 200
630
+ 201
631
+ 202
632
+ 203
633
+ 204
634
+ 205
635
+ 206
636
+ 207
637
+ 208</pre>
638
+ </td>
639
+ <td>
640
+ <pre class="code"><span class="info file"># File 'lib/erbook/template.rb', line 196</span>
641
+
642
+ <span class='def def kw'>def</span> <span class='content_from_block identifier id'>content_from_block</span> <span class='mult op'>*</span><span class='block_args identifier id'>block_args</span>
643
+ <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='comma token'>,</span> <span class='string val'>'block must be given'</span> <span class='unless unless_mod kw'>unless</span> <span class='block_given? fid id'>block_given?</span>
644
+
645
+ <span class='head identifier id'>head</span> <span class='assign token'>=</span> <span class='@buffer ivar id'>@buffer</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
646
+ <span class='body identifier id'>body</span> <span class='assign token'>=</span> <span class='yield yield kw'>yield</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='block_args identifier id'>block_args</span><span class='rparen token'>)</span> <span class='comment val'># this appends 'content' to '@buffer'</span>
647
+ <span class='tail identifier id'>tail</span> <span class='assign token'>=</span> <span class='@buffer ivar id'>@buffer</span><span class='dot token'>.</span><span class='length identifier id'>length</span>
648
+
649
+ <span class='if if kw'>if</span> <span class='tail identifier id'>tail</span> <span class='gt op'>&gt;</span> <span class='head identifier id'>head</span>
650
+ <span class='@buffer ivar id'>@buffer</span><span class='dot token'>.</span><span class='slice! fid id'>slice!</span> <span class='head identifier id'>head</span><span class='dot2 op'>..</span><span class='tail identifier id'>tail</span>
651
+ <span class='else else kw'>else</span>
652
+ <span class='body identifier id'>body</span>
653
+ <span class='end end kw'>end</span><span class='dot token'>.</span><span class='to_s identifier id'>to_s</span>
654
+ <span class='end end kw'>end</span>
655
+ </pre>
656
+ </td>
657
+ </tr>
658
+ </table>
659
+ </div>
660
+ </div>
661
+ </div>
662
+ </div>
663
+
664
+ </div>
665
+ </div>
666
+
667
+ </div>
668
+ </div>
669
+ </body>
670
+ </html>