erubis 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/ChangeLog +150 -2
  2. data/LGPL +504 -0
  3. data/README.txt +14 -8
  4. data/benchmark/erubybench.rb +1 -1
  5. data/benchmark/erubybench.rhtml +3 -3
  6. data/bin/erubis +1 -1
  7. data/bin/notext +154 -0
  8. data/contrib/erubis +1036 -374
  9. data/contrib/inline-require +5 -3
  10. data/doc-api/classes/Erubis.html +43 -1
  11. data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
  12. data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
  13. data/doc-api/classes/Erubis/Basic.html +112 -0
  14. data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
  15. data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
  16. data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
  17. data/doc-api/classes/Erubis/CGenerator.html +386 -0
  18. data/doc-api/classes/Erubis/Context.html +31 -32
  19. data/doc-api/classes/Erubis/Converter.html +231 -0
  20. data/doc-api/classes/Erubis/Ec.html +9 -283
  21. data/doc-api/classes/Erubis/Ejava.html +9 -274
  22. data/doc-api/classes/Erubis/Ejavascript.html +9 -298
  23. data/doc-api/classes/Erubis/Engine.html +68 -508
  24. data/doc-api/classes/Erubis/Eperl.html +9 -259
  25. data/doc-api/classes/Erubis/Ephp.html +9 -239
  26. data/doc-api/classes/Erubis/ErubisError.html +2 -2
  27. data/doc-api/classes/Erubis/Eruby.html +4 -187
  28. data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
  29. data/doc-api/classes/Erubis/Escheme.html +9 -272
  30. data/doc-api/classes/Erubis/Evaluator.html +212 -0
  31. data/doc-api/classes/Erubis/Generator.html +410 -0
  32. data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
  33. data/doc-api/classes/Erubis/Helper.html +112 -0
  34. data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
  35. data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
  36. data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
  37. data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
  38. data/doc-api/classes/Erubis/Main.html +27 -25
  39. data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
  40. data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
  41. data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
  42. data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
  43. data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
  44. data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
  45. data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
  46. data/doc-api/classes/Erubis/PI.html +124 -0
  47. data/doc-api/classes/Erubis/PI/Converter.html +318 -0
  48. data/doc-api/classes/Erubis/PI/Ec.html +166 -0
  49. data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
  50. data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
  51. data/doc-api/classes/Erubis/PI/Engine.html +122 -0
  52. data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
  53. data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
  54. data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
  55. data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
  56. data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
  57. data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
  58. data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
  59. data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
  60. data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
  61. data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
  62. data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
  63. data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
  64. data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
  65. data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
  66. data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
  67. data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
  68. data/doc-api/classes/Erubis/TinyEruby.html +45 -40
  69. data/doc-api/classes/Erubis/XmlHelper.html +14 -14
  70. data/doc-api/created.rid +1 -1
  71. data/doc-api/files/__/README_txt.html +27 -9
  72. data/doc-api/files/erubis/context_rb.html +107 -0
  73. data/doc-api/files/erubis/converter_rb.html +114 -0
  74. data/doc-api/files/erubis/engine/ec_rb.html +2 -2
  75. data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
  76. data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
  77. data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
  78. data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
  79. data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
  80. data/doc-api/files/erubis/engine/eruby_rb.html +3 -2
  81. data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
  82. data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
  83. data/doc-api/files/erubis/engine_rb.html +6 -3
  84. data/doc-api/files/erubis/enhancer_rb.html +2 -9
  85. data/doc-api/files/erubis/error_rb.html +107 -0
  86. data/doc-api/files/erubis/evaluator_rb.html +115 -0
  87. data/doc-api/files/erubis/generator_rb.html +114 -0
  88. data/doc-api/files/erubis/helper/rails_rb.html +140 -0
  89. data/doc-api/files/erubis/helper_rb.html +1 -1
  90. data/doc-api/files/erubis/local-setting_rb.html +1 -1
  91. data/doc-api/files/erubis/main_rb.html +2 -2
  92. data/doc-api/files/erubis/tiny_rb.html +2 -2
  93. data/doc-api/files/erubis_rb.html +2 -2
  94. data/doc-api/fr_class_index.html +32 -0
  95. data/doc-api/fr_file_index.html +6 -0
  96. data/doc-api/fr_method_index.html +178 -136
  97. data/doc/users-guide.html +538 -199
  98. data/examples/{Makefile → basic/Makefile} +11 -11
  99. data/examples/basic/example.ec +42 -0
  100. data/examples/{example.ejava → basic/example.ejava} +5 -1
  101. data/examples/{example.ejavascript → basic/example.ejs} +0 -0
  102. data/examples/{example.eperl → basic/example.eperl} +2 -2
  103. data/examples/{example.ephp → basic/example.ephp} +0 -0
  104. data/examples/{example.eruby → basic/example.eruby} +0 -0
  105. data/examples/{example.escheme → basic/example.escheme} +0 -0
  106. data/examples/pi/Makefile +54 -0
  107. data/examples/pi/example.ec +42 -0
  108. data/examples/pi/example.ejava +45 -0
  109. data/examples/pi/example.ejs +16 -0
  110. data/examples/pi/example.eperl +16 -0
  111. data/examples/pi/example.ephp +17 -0
  112. data/examples/pi/example.eruby +15 -0
  113. data/examples/pi/example.escheme +26 -0
  114. data/lib/erubis.rb +15 -8
  115. data/lib/erubis/context.rb +54 -0
  116. data/lib/erubis/converter.rb +307 -0
  117. data/lib/erubis/engine.rb +57 -227
  118. data/lib/erubis/engine/ec.rb +31 -20
  119. data/lib/erubis/engine/ejava.rb +33 -21
  120. data/lib/erubis/engine/ejavascript.rb +30 -18
  121. data/lib/erubis/engine/enhanced.rb +7 -2
  122. data/lib/erubis/engine/eperl.rb +33 -19
  123. data/lib/erubis/engine/ephp.rb +32 -14
  124. data/lib/erubis/engine/eruby.rb +34 -7
  125. data/lib/erubis/engine/escheme.rb +34 -15
  126. data/lib/erubis/engine/optimized.rb +25 -11
  127. data/lib/erubis/enhancer.rb +53 -19
  128. data/lib/erubis/error.rb +24 -0
  129. data/lib/erubis/evaluator.rb +71 -0
  130. data/lib/erubis/generator.rb +83 -0
  131. data/lib/erubis/helper.rb +1 -1
  132. data/lib/erubis/helper/rails.rb +159 -0
  133. data/lib/erubis/local-setting.rb +1 -1
  134. data/lib/erubis/main.rb +87 -46
  135. data/lib/erubis/tiny.rb +81 -7
  136. data/test/assert-text-equal.rb +1 -1
  137. data/test/test-engines.rb +8 -9
  138. data/test/test-erubis.rb +196 -18
  139. data/test/{test-bin.rb → test-main.rb} +123 -21
  140. data/test/test-notext.rb +27 -0
  141. data/test/test.rb +5 -3
  142. data/test/testutil.rb +25 -36
  143. metadata +75 -13
  144. data/COPYING +0 -340
  145. data/examples/example.ec +0 -24
@@ -139,8 +139,8 @@ this is language-independent.
139
139
  <h3 class="section-bar">Methods</h3>
140
140
 
141
141
  <div class="name-list">
142
- <a href="#M000009">add_text</a>&nbsp;&nbsp;
143
- <a href="#M000010">compile</a>&nbsp;&nbsp;
142
+ <a href="#M000078">add_text</a>&nbsp;&nbsp;
143
+ <a href="#M000079">convert</a>&nbsp;&nbsp;
144
144
  </div>
145
145
  </div>
146
146
 
@@ -193,21 +193,21 @@ this is language-independent.
193
193
  <div id="methods">
194
194
  <h3 class="section-bar">Public Instance methods</h3>
195
195
 
196
- <div id="method-M000009" class="method-detail">
197
- <a name="M000009"></a>
196
+ <div id="method-M000078" class="method-detail">
197
+ <a name="M000078"></a>
198
198
 
199
199
  <div class="method-heading">
200
- <a href="#M000009" class="method-signature">
200
+ <a href="#M000078" class="method-signature">
201
201
  <span class="method-name">add_text</span><span class="method-args">(src, text)</span>
202
202
  </a>
203
203
  </div>
204
204
 
205
205
  <div class="method-description">
206
206
  <p><a class="source-toggle" href="#"
207
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
208
- <div class="method-source-code" id="M000009-source">
207
+ onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
208
+ <div class="method-source-code" id="M000078-source">
209
209
  <pre>
210
- <span class="ruby-comment cmt"># File erubis/enhancer.rb, line 464</span>
210
+ <span class="ruby-comment cmt"># File erubis/enhancer.rb, line 498</span>
211
211
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_text</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">text</span>)
212
212
  <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">HEADER_FOOTER_PATTERN</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">txt</span>, <span class="ruby-identifier">lspace</span>, <span class="ruby-identifier">word</span>, <span class="ruby-identifier">content</span>, <span class="ruby-identifier">rspace</span><span class="ruby-operator">|</span>
213
213
  <span class="ruby-identifier">flag_trim</span> = <span class="ruby-ivar">@trim</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">rspace</span>
@@ -225,22 +225,22 @@ this is language-independent.
225
225
  </div>
226
226
  </div>
227
227
 
228
- <div id="method-M000010" class="method-detail">
229
- <a name="M000010"></a>
228
+ <div id="method-M000079" class="method-detail">
229
+ <a name="M000079"></a>
230
230
 
231
231
  <div class="method-heading">
232
- <a href="#M000010" class="method-signature">
233
- <span class="method-name">compile</span><span class="method-args">(input)</span>
232
+ <a href="#M000079" class="method-signature">
233
+ <span class="method-name">convert</span><span class="method-args">(input)</span>
234
234
  </a>
235
235
  </div>
236
236
 
237
237
  <div class="method-description">
238
238
  <p><a class="source-toggle" href="#"
239
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
240
- <div class="method-source-code" id="M000010-source">
239
+ onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
240
+ <div class="method-source-code" id="M000079-source">
241
241
  <pre>
242
- <span class="ruby-comment cmt"># File erubis/enhancer.rb, line 479</span>
243
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">input</span>)
242
+ <span class="ruby-comment cmt"># File erubis/enhancer.rb, line 513</span>
243
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
244
244
  <span class="ruby-identifier">source</span> = <span class="ruby-keyword kw">super</span>
245
245
  <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@src</span> = <span class="ruby-node">&quot;#{@header}#{source}#{@footer}&quot;</span>
246
246
  <span class="ruby-keyword kw">end</span>
@@ -0,0 +1,112 @@
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>Module: Erubis::Helper</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>Module</strong></td>
53
+ <td class="class-name-in-header">Erubis::Helper</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/erubis/helper/rails_rb.html">
59
+ erubis/helper/rails.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+
80
+ </div>
81
+
82
+
83
+ <!-- if includes -->
84
+
85
+ <div id="section">
86
+
87
+ <div id="class-list">
88
+ <h3 class="section-bar">Classes and Modules</h3>
89
+
90
+ Class <a href="Helper/CachedRailsTemplate.html" class="link">Erubis::Helper::CachedRailsTemplate</a><br />
91
+ Class <a href="Helper/RailsTemplate.html" class="link">Erubis::Helper::RailsTemplate</a><br />
92
+
93
+ </div>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <!-- if method_list -->
102
+
103
+
104
+ </div>
105
+
106
+
107
+ <div id="validator-badges">
108
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,198 @@
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: Erubis::Helper::CachedRailsTemplate</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">Erubis::Helper::CachedRailsTemplate</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/erubis/helper/rails_rb.html">
59
+ erubis/helper/rails.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="RailsTemplate.html">
69
+ RailsTemplate
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
+
84
+
85
+ </div>
86
+
87
+ <div id="method-list">
88
+ <h3 class="section-bar">Methods</h3>
89
+
90
+ <div class="name-list">
91
+ <a href="#M000142">_evaluate_proc</a>&nbsp;&nbsp;
92
+ <a href="#M000141">render</a>&nbsp;&nbsp;
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+
98
+
99
+ <!-- if includes -->
100
+
101
+ <div id="section">
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ <!-- if method_list -->
111
+ <div id="methods">
112
+ <h3 class="section-bar">Public Instance methods</h3>
113
+
114
+ <div id="method-M000141" class="method-detail">
115
+ <a name="M000141"></a>
116
+
117
+ <div class="method-heading">
118
+ <a href="#M000141" class="method-signature">
119
+ <span class="method-name">render</span><span class="method-args">(template, assigns)</span>
120
+ </a>
121
+ </div>
122
+
123
+ <div class="method-description">
124
+ <p><a class="source-toggle" href="#"
125
+ onclick="toggleCode('M000141-source');return false;">[Source]</a></p>
126
+ <div class="method-source-code" id="M000141-source">
127
+ <pre>
128
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 118</span>
129
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">assigns</span>)
130
+ <span class="ruby-comment cmt">## template path without suffix</span>
131
+ <span class="ruby-comment cmt">## (how to get template path name with suffix? I can't find...)</span>
132
+ <span class="ruby-identifier">c</span> = <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">controller</span>
133
+ <span class="ruby-identifier">template_basename</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">template_root</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">controller_name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">action_name</span>
134
+
135
+ <span class="ruby-comment cmt">## cache template</span>
136
+ <span class="ruby-identifier">proc_obj</span> = <span class="ruby-ivar">@@cache_table</span>[<span class="ruby-identifier">template_basename</span>]
137
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">proc_obj</span>
138
+ <span class="ruby-identifier">code</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">template</span>)
139
+ <span class="ruby-identifier">proc_obj</span> = <span class="ruby-identifier">eval</span>(<span class="ruby-node">&quot;proc do #{code} end&quot;</span>)
140
+ <span class="ruby-ivar">@@cache_table</span>[<span class="ruby-identifier">template_basename</span>] = <span class="ruby-identifier">proc_obj</span>
141
+ <span class="ruby-keyword kw">end</span>
142
+
143
+ <span class="ruby-comment cmt">## use @view as context object</span>
144
+ <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:evaluate_assigns</span>)
145
+ <span class="ruby-comment cmt">#or @view.instance_eval(&quot;evaluate_assigns()&quot;)</span>
146
+ <span class="ruby-identifier">context</span> = <span class="ruby-ivar">@view</span>
147
+
148
+ <span class="ruby-comment cmt">## evaluate ruby code with context object</span>
149
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assigns</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">assigns</span>.<span class="ruby-identifier">empty?</span>
150
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_evaluate_proc</span>(<span class="ruby-identifier">proc_obj</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">assigns</span>)
151
+ <span class="ruby-keyword kw">else</span>
152
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">proc_obj</span>)
153
+ <span class="ruby-keyword kw">end</span>
154
+ <span class="ruby-keyword kw">end</span>
155
+ </pre>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <h3 class="section-bar">Protected Instance methods</h3>
161
+
162
+ <div id="method-M000142" class="method-detail">
163
+ <a name="M000142"></a>
164
+
165
+ <div class="method-heading">
166
+ <a href="#M000142" class="method-signature">
167
+ <span class="method-name">_evaluate_proc</span><span class="method-args">(_proc_obj, _context, _localvars)</span>
168
+ </a>
169
+ </div>
170
+
171
+ <div class="method-description">
172
+ <p><a class="source-toggle" href="#"
173
+ onclick="toggleCode('M000142-source');return false;">[Source]</a></p>
174
+ <div class="method-source-code" id="M000142-source">
175
+ <pre>
176
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 149</span>
177
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_evaluate_proc</span>(<span class="ruby-identifier">_proc_obj</span>, <span class="ruby-identifier">_context</span>, <span class="ruby-identifier">_localvars</span>)
178
+ <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">_localvar_code</span>(<span class="ruby-identifier">_localvars</span>))
179
+ <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">_proc_obj</span>)
180
+ <span class="ruby-keyword kw">end</span>
181
+ </pre>
182
+ </div>
183
+ </div>
184
+ </div>
185
+
186
+
187
+ </div>
188
+
189
+
190
+ </div>
191
+
192
+
193
+ <div id="validator-badges">
194
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
195
+ </div>
196
+
197
+ </body>
198
+ </html>
@@ -0,0 +1,366 @@
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: Erubis::Helper::RailsTemplate</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">Erubis::Helper::RailsTemplate</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/erubis/helper/rails_rb.html">
59
+ erubis/helper/rails.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
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000151">_evaluate_string</a>&nbsp;&nbsp;
90
+ <a href="#M000150">_localvar_code</a>&nbsp;&nbsp;
91
+ <a href="#M000148">convert</a>&nbsp;&nbsp;
92
+ <a href="#M000145">default_properties</a>&nbsp;&nbsp;
93
+ <a href="#M000146">default_properties=</a>&nbsp;&nbsp;
94
+ <a href="#M000143">engine_class</a>&nbsp;&nbsp;
95
+ <a href="#M000144">engine_class=</a>&nbsp;&nbsp;
96
+ <a href="#M000147">new</a>&nbsp;&nbsp;
97
+ <a href="#M000149">render</a>&nbsp;&nbsp;
98
+ </div>
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ <!-- if includes -->
105
+
106
+ <div id="section">
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <!-- if method_list -->
116
+ <div id="methods">
117
+ <h3 class="section-bar">Public Class methods</h3>
118
+
119
+ <div id="method-M000145" class="method-detail">
120
+ <a name="M000145"></a>
121
+
122
+ <div class="method-heading">
123
+ <a href="#M000145" class="method-signature">
124
+ <span class="method-name">default_properties</span><span class="method-args">()</span>
125
+ </a>
126
+ </div>
127
+
128
+ <div class="method-description">
129
+ <p><a class="source-toggle" href="#"
130
+ onclick="toggleCode('M000145-source');return false;">[Source]</a></p>
131
+ <div class="method-source-code" id="M000145-source">
132
+ <pre>
133
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 49</span>
134
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default_properties</span>
135
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@default_properties</span>
136
+ <span class="ruby-keyword kw">end</span>
137
+ </pre>
138
+ </div>
139
+ </div>
140
+ </div>
141
+
142
+ <div id="method-M000146" class="method-detail">
143
+ <a name="M000146"></a>
144
+
145
+ <div class="method-heading">
146
+ <a href="#M000146" class="method-signature">
147
+ <span class="method-name">default_properties=</span><span class="method-args">(properties)</span>
148
+ </a>
149
+ </div>
150
+
151
+ <div class="method-description">
152
+ <p><a class="source-toggle" href="#"
153
+ onclick="toggleCode('M000146-source');return false;">[Source]</a></p>
154
+ <div class="method-source-code" id="M000146-source">
155
+ <pre>
156
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 53</span>
157
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default_properties=</span>(<span class="ruby-identifier">properties</span>)
158
+ <span class="ruby-ivar">@@default_properties</span> = <span class="ruby-identifier">properties</span>
159
+ <span class="ruby-keyword kw">end</span>
160
+ </pre>
161
+ </div>
162
+ </div>
163
+ </div>
164
+
165
+ <div id="method-M000143" class="method-detail">
166
+ <a name="M000143"></a>
167
+
168
+ <div class="method-heading">
169
+ <a href="#M000143" class="method-signature">
170
+ <span class="method-name">engine_class</span><span class="method-args">()</span>
171
+ </a>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+ <p><a class="source-toggle" href="#"
176
+ onclick="toggleCode('M000143-source');return false;">[Source]</a></p>
177
+ <div class="method-source-code" id="M000143-source">
178
+ <pre>
179
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 35</span>
180
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">engine_class</span>
181
+ <span class="ruby-ivar">@@engine_class</span>
182
+ <span class="ruby-keyword kw">end</span>
183
+ </pre>
184
+ </div>
185
+ </div>
186
+ </div>
187
+
188
+ <div id="method-M000144" class="method-detail">
189
+ <a name="M000144"></a>
190
+
191
+ <div class="method-heading">
192
+ <a href="#M000144" class="method-signature">
193
+ <span class="method-name">engine_class=</span><span class="method-args">(klass)</span>
194
+ </a>
195
+ </div>
196
+
197
+ <div class="method-description">
198
+ <p><a class="source-toggle" href="#"
199
+ onclick="toggleCode('M000144-source');return false;">[Source]</a></p>
200
+ <div class="method-source-code" id="M000144-source">
201
+ <pre>
202
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 39</span>
203
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">engine_class=</span>(<span class="ruby-identifier">klass</span>)
204
+ <span class="ruby-ivar">@@engine_class</span> = <span class="ruby-identifier">klass</span>
205
+ <span class="ruby-ivar">@@engine_instance</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>
206
+ <span class="ruby-keyword kw">end</span>
207
+ </pre>
208
+ </div>
209
+ </div>
210
+ </div>
211
+
212
+ <div id="method-M000147" class="method-detail">
213
+ <a name="M000147"></a>
214
+
215
+ <div class="method-heading">
216
+ <a href="#M000147" class="method-signature">
217
+ <span class="method-name">new</span><span class="method-args">(view)</span>
218
+ </a>
219
+ </div>
220
+
221
+ <div class="method-description">
222
+ <p>
223
+ cattr_accessor :<a href="RailsTemplate.html#M000145">default_properties</a>
224
+ </p>
225
+ <p><a class="source-toggle" href="#"
226
+ onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
227
+ <div class="method-source-code" id="M000147-source">
228
+ <pre>
229
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 60</span>
230
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">view</span>)
231
+ <span class="ruby-ivar">@view</span> = <span class="ruby-identifier">view</span>
232
+ <span class="ruby-comment cmt">#@@engine_instance ||= @@engine_class.new(nil, @@default_properties)</span>
233
+ <span class="ruby-keyword kw">end</span>
234
+ </pre>
235
+ </div>
236
+ </div>
237
+ </div>
238
+
239
+ <h3 class="section-bar">Public Instance methods</h3>
240
+
241
+ <div id="method-M000148" class="method-detail">
242
+ <a name="M000148"></a>
243
+
244
+ <div class="method-heading">
245
+ <a href="#M000148" class="method-signature">
246
+ <span class="method-name">convert</span><span class="method-args">(template)</span>
247
+ </a>
248
+ </div>
249
+
250
+ <div class="method-description">
251
+ <p><a class="source-toggle" href="#"
252
+ onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
253
+ <div class="method-source-code" id="M000148-source">
254
+ <pre>
255
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 66</span>
256
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">template</span>)
257
+ <span class="ruby-comment cmt">#code = @@engine_instance.convert(template)</span>
258
+ <span class="ruby-comment cmt">#return code</span>
259
+ <span class="ruby-identifier">engine</span> = <span class="ruby-ivar">@@engine_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@@default_properties</span>)
260
+ <span class="ruby-identifier">code</span> = <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">template</span>)
261
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">code</span>
262
+ <span class="ruby-keyword kw">end</span>
263
+ </pre>
264
+ </div>
265
+ </div>
266
+ </div>
267
+
268
+ <div id="method-M000149" class="method-detail">
269
+ <a name="M000149"></a>
270
+
271
+ <div class="method-heading">
272
+ <a href="#M000149" class="method-signature">
273
+ <span class="method-name">render</span><span class="method-args">(template, assigns)</span>
274
+ </a>
275
+ </div>
276
+
277
+ <div class="method-description">
278
+ <p><a class="source-toggle" href="#"
279
+ onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
280
+ <div class="method-source-code" id="M000149-source">
281
+ <pre>
282
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 75</span>
283
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">assigns</span>)
284
+ <span class="ruby-comment cmt">## get ruby code</span>
285
+ <span class="ruby-identifier">code</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">template</span>)
286
+
287
+ <span class="ruby-comment cmt">## use @view as context object</span>
288
+ <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:evaluate_assigns</span>) <span class="ruby-comment cmt">#or @view.instance_eval(&quot;evaluate_assigns()&quot;)</span>
289
+ <span class="ruby-identifier">context</span> = <span class="ruby-ivar">@view</span>
290
+
291
+ <span class="ruby-comment cmt">## evaluate ruby code with context object</span>
292
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assigns</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">assigns</span>.<span class="ruby-identifier">empty?</span>
293
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_evaluate_string</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">assigns</span>)
294
+ <span class="ruby-keyword kw">else</span>
295
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-identifier">code</span>)
296
+ <span class="ruby-keyword kw">end</span>
297
+ <span class="ruby-keyword kw">end</span>
298
+ </pre>
299
+ </div>
300
+ </div>
301
+ </div>
302
+
303
+ <h3 class="section-bar">Protected Instance methods</h3>
304
+
305
+ <div id="method-M000151" class="method-detail">
306
+ <a name="M000151"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="#M000151" class="method-signature">
310
+ <span class="method-name">_evaluate_string</span><span class="method-args">(_code, _context, _localvars)</span>
311
+ </a>
312
+ </div>
313
+
314
+ <div class="method-description">
315
+ <p><a class="source-toggle" href="#"
316
+ onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
317
+ <div class="method-source-code" id="M000151-source">
318
+ <pre>
319
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 102</span>
320
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_evaluate_string</span>(<span class="ruby-identifier">_code</span>, <span class="ruby-identifier">_context</span>, <span class="ruby-identifier">_localvars</span>)
321
+ <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">_localvar_code</span>(<span class="ruby-identifier">_localvars</span>))
322
+ <span class="ruby-identifier">_context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-identifier">_code</span>)
323
+ <span class="ruby-keyword kw">end</span>
324
+ </pre>
325
+ </div>
326
+ </div>
327
+ </div>
328
+
329
+ <div id="method-M000150" class="method-detail">
330
+ <a name="M000150"></a>
331
+
332
+ <div class="method-heading">
333
+ <a href="#M000150" class="method-signature">
334
+ <span class="method-name">_localvar_code</span><span class="method-args">(_localvars)</span>
335
+ </a>
336
+ </div>
337
+
338
+ <div class="method-description">
339
+ <p><a class="source-toggle" href="#"
340
+ onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
341
+ <div class="method-source-code" id="M000150-source">
342
+ <pre>
343
+ <span class="ruby-comment cmt"># File erubis/helper/rails.rb, line 95</span>
344
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_localvar_code</span>(<span class="ruby-identifier">_localvars</span>)
345
+ <span class="ruby-identifier">list</span> = <span class="ruby-identifier">_localvars</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_name</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{_name} = _localvars[#{_name.inspect}]\n&quot;</span> }
346
+ <span class="ruby-identifier">code</span> = <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>()
347
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">code</span>
348
+ <span class="ruby-keyword kw">end</span>
349
+ </pre>
350
+ </div>
351
+ </div>
352
+ </div>
353
+
354
+
355
+ </div>
356
+
357
+
358
+ </div>
359
+
360
+
361
+ <div id="validator-badges">
362
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
363
+ </div>
364
+
365
+ </body>
366
+ </html>