erubis 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +150 -2
- data/LGPL +504 -0
- data/README.txt +14 -8
- data/benchmark/erubybench.rb +1 -1
- data/benchmark/erubybench.rhtml +3 -3
- data/bin/erubis +1 -1
- data/bin/notext +154 -0
- data/contrib/erubis +1036 -374
- data/contrib/inline-require +5 -3
- data/doc-api/classes/Erubis.html +43 -1
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
- data/doc-api/classes/Erubis/Basic.html +112 -0
- data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
- data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +386 -0
- data/doc-api/classes/Erubis/Context.html +31 -32
- data/doc-api/classes/Erubis/Converter.html +231 -0
- data/doc-api/classes/Erubis/Ec.html +9 -283
- data/doc-api/classes/Erubis/Ejava.html +9 -274
- data/doc-api/classes/Erubis/Ejavascript.html +9 -298
- data/doc-api/classes/Erubis/Engine.html +68 -508
- data/doc-api/classes/Erubis/Eperl.html +9 -259
- data/doc-api/classes/Erubis/Ephp.html +9 -239
- data/doc-api/classes/Erubis/ErubisError.html +2 -2
- data/doc-api/classes/Erubis/Eruby.html +4 -187
- data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
- data/doc-api/classes/Erubis/Escheme.html +9 -272
- data/doc-api/classes/Erubis/Evaluator.html +212 -0
- data/doc-api/classes/Erubis/Generator.html +410 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
- data/doc-api/classes/Erubis/Helper.html +112 -0
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
- data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
- data/doc-api/classes/Erubis/Main.html +27 -25
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
- data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
- data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
- data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
- data/doc-api/classes/Erubis/PI.html +124 -0
- data/doc-api/classes/Erubis/PI/Converter.html +318 -0
- data/doc-api/classes/Erubis/PI/Ec.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
- data/doc-api/classes/Erubis/PI/Engine.html +122 -0
- data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
- data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
- data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
- data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
- data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
- data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
- data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
- data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
- data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
- data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
- data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/TinyEruby.html +45 -40
- data/doc-api/classes/Erubis/XmlHelper.html +14 -14
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +27 -9
- data/doc-api/files/erubis/context_rb.html +107 -0
- data/doc-api/files/erubis/converter_rb.html +114 -0
- data/doc-api/files/erubis/engine/ec_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
- data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
- data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
- data/doc-api/files/erubis/engine/eruby_rb.html +3 -2
- data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
- data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
- data/doc-api/files/erubis/engine_rb.html +6 -3
- data/doc-api/files/erubis/enhancer_rb.html +2 -9
- data/doc-api/files/erubis/error_rb.html +107 -0
- data/doc-api/files/erubis/evaluator_rb.html +115 -0
- data/doc-api/files/erubis/generator_rb.html +114 -0
- data/doc-api/files/erubis/helper/rails_rb.html +140 -0
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +2 -2
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +32 -0
- data/doc-api/fr_file_index.html +6 -0
- data/doc-api/fr_method_index.html +178 -136
- data/doc/users-guide.html +538 -199
- data/examples/{Makefile → basic/Makefile} +11 -11
- data/examples/basic/example.ec +42 -0
- data/examples/{example.ejava → basic/example.ejava} +5 -1
- data/examples/{example.ejavascript → basic/example.ejs} +0 -0
- data/examples/{example.eperl → basic/example.eperl} +2 -2
- data/examples/{example.ephp → basic/example.ephp} +0 -0
- data/examples/{example.eruby → basic/example.eruby} +0 -0
- data/examples/{example.escheme → basic/example.escheme} +0 -0
- data/examples/pi/Makefile +54 -0
- data/examples/pi/example.ec +42 -0
- data/examples/pi/example.ejava +45 -0
- data/examples/pi/example.ejs +16 -0
- data/examples/pi/example.eperl +16 -0
- data/examples/pi/example.ephp +17 -0
- data/examples/pi/example.eruby +15 -0
- data/examples/pi/example.escheme +26 -0
- data/lib/erubis.rb +15 -8
- data/lib/erubis/context.rb +54 -0
- data/lib/erubis/converter.rb +307 -0
- data/lib/erubis/engine.rb +57 -227
- data/lib/erubis/engine/ec.rb +31 -20
- data/lib/erubis/engine/ejava.rb +33 -21
- data/lib/erubis/engine/ejavascript.rb +30 -18
- data/lib/erubis/engine/enhanced.rb +7 -2
- data/lib/erubis/engine/eperl.rb +33 -19
- data/lib/erubis/engine/ephp.rb +32 -14
- data/lib/erubis/engine/eruby.rb +34 -7
- data/lib/erubis/engine/escheme.rb +34 -15
- data/lib/erubis/engine/optimized.rb +25 -11
- data/lib/erubis/enhancer.rb +53 -19
- data/lib/erubis/error.rb +24 -0
- data/lib/erubis/evaluator.rb +71 -0
- data/lib/erubis/generator.rb +83 -0
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helper/rails.rb +159 -0
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +87 -46
- data/lib/erubis/tiny.rb +81 -7
- data/test/assert-text-equal.rb +1 -1
- data/test/test-engines.rb +8 -9
- data/test/test-erubis.rb +196 -18
- data/test/{test-bin.rb → test-main.rb} +123 -21
- data/test/test-notext.rb +27 -0
- data/test/test.rb +5 -3
- data/test/testutil.rb +25 -36
- metadata +75 -13
- data/COPYING +0 -340
- data/examples/example.ec +0 -24
@@ -0,0 +1,166 @@
|
|
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::PI::Escheme</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::PI::Escheme</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/erubis/engine/escheme_rb.html">
|
59
|
+
erubis/engine/escheme.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
|
+
PI::Engine
|
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
|
+
class XmlEscheme < <a href="Escheme.html">Escheme</a>
|
84
|
+
</p>
|
85
|
+
<pre>
|
86
|
+
include EscapeEnhancer
|
87
|
+
</pre>
|
88
|
+
<p>
|
89
|
+
end
|
90
|
+
</p>
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div id="method-list">
|
98
|
+
<h3 class="section-bar">Methods</h3>
|
99
|
+
|
100
|
+
<div class="name-list">
|
101
|
+
<a href="#M000053">init_converter</a>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if includes -->
|
109
|
+
<div id="includes">
|
110
|
+
<h3 class="section-bar">Included Modules</h3>
|
111
|
+
|
112
|
+
<div id="includes-list">
|
113
|
+
<span class="include-name"><a href="../SchemeGenerator.html">SchemeGenerator</a></span>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div id="section">
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
<!-- if method_list -->
|
127
|
+
<div id="methods">
|
128
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
129
|
+
|
130
|
+
<div id="method-M000053" class="method-detail">
|
131
|
+
<a name="M000053"></a>
|
132
|
+
|
133
|
+
<div class="method-heading">
|
134
|
+
<a href="#M000053" class="method-signature">
|
135
|
+
<span class="method-name">init_converter</span><span class="method-args">(properties={})</span>
|
136
|
+
</a>
|
137
|
+
</div>
|
138
|
+
|
139
|
+
<div class="method-description">
|
140
|
+
<p><a class="source-toggle" href="#"
|
141
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
142
|
+
<div class="method-source-code" id="M000053-source">
|
143
|
+
<pre>
|
144
|
+
<span class="ruby-comment cmt"># File erubis/engine/escheme.rb, line 107</span>
|
145
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">init_converter</span>(<span class="ruby-identifier">properties</span>={})
|
146
|
+
<span class="ruby-ivar">@pi</span> = <span class="ruby-value str">'scheme'</span>
|
147
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">properties</span>)
|
148
|
+
<span class="ruby-keyword kw">end</span>
|
149
|
+
</pre>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
</div>
|
156
|
+
|
157
|
+
|
158
|
+
</div>
|
159
|
+
|
160
|
+
|
161
|
+
<div id="validator-badges">
|
162
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
163
|
+
</div>
|
164
|
+
|
165
|
+
</body>
|
166
|
+
</html>
|
@@ -0,0 +1,305 @@
|
|
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::PI::TinyEruby</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::PI::TinyEruby</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/erubis/tiny_rb.html">
|
59
|
+
erubis/tiny.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="#M000046">convert</a>
|
90
|
+
<a href="#M000047">escape_text</a>
|
91
|
+
<a href="#M000049">evaluate</a>
|
92
|
+
<a href="#M000045">new</a>
|
93
|
+
<a href="#M000048">result</a>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if includes -->
|
101
|
+
|
102
|
+
<div id="section">
|
103
|
+
|
104
|
+
|
105
|
+
<div id="constants-list">
|
106
|
+
<h3 class="section-bar">Constants</h3>
|
107
|
+
|
108
|
+
<div class="name-list">
|
109
|
+
<table summary="Constants">
|
110
|
+
<tr class="top-aligned-row context-row">
|
111
|
+
<td class="context-item-name">EMBEDDED_PATTERN</td>
|
112
|
+
<td>=</td>
|
113
|
+
<td class="context-item-value">/(^[ \t]*)?<\?rb(\s.*?)\?>([ \t]*\r?\n)?|\$(!*)?\{(.*?)\}/</td>
|
114
|
+
</tr>
|
115
|
+
</table>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<div id="attribute-list">
|
122
|
+
<h3 class="section-bar">Attributes</h3>
|
123
|
+
|
124
|
+
<div class="name-list">
|
125
|
+
<table>
|
126
|
+
<tr class="top-aligned-row context-row">
|
127
|
+
<td class="context-item-name">src</td>
|
128
|
+
<td class="context-item-value"> [R] </td>
|
129
|
+
<td class="context-item-desc"></td>
|
130
|
+
</tr>
|
131
|
+
</table>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<!-- if method_list -->
|
138
|
+
<div id="methods">
|
139
|
+
<h3 class="section-bar">Public Class methods</h3>
|
140
|
+
|
141
|
+
<div id="method-M000045" class="method-detail">
|
142
|
+
<a name="M000045"></a>
|
143
|
+
|
144
|
+
<div class="method-heading">
|
145
|
+
<a href="#M000045" class="method-signature">
|
146
|
+
<span class="method-name">new</span><span class="method-args">(input=nil, options={})</span>
|
147
|
+
</a>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div class="method-description">
|
151
|
+
<p><a class="source-toggle" href="#"
|
152
|
+
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
153
|
+
<div class="method-source-code" id="M000045-source">
|
154
|
+
<pre>
|
155
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 77</span>
|
156
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">input</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>={})
|
157
|
+
<span class="ruby-ivar">@escape</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:escape</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'Erubis::XmlHelper.escape_xml'</span>
|
158
|
+
<span class="ruby-ivar">@src</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span>
|
159
|
+
<span class="ruby-keyword kw">end</span>
|
160
|
+
</pre>
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
</div>
|
164
|
+
|
165
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
166
|
+
|
167
|
+
<div id="method-M000046" class="method-detail">
|
168
|
+
<a name="M000046"></a>
|
169
|
+
|
170
|
+
<div class="method-heading">
|
171
|
+
<a href="#M000046" class="method-signature">
|
172
|
+
<span class="method-name">convert</span><span class="method-args">(input)</span>
|
173
|
+
</a>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div class="method-description">
|
177
|
+
<p><a class="source-toggle" href="#"
|
178
|
+
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
179
|
+
<div class="method-source-code" id="M000046-source">
|
180
|
+
<pre>
|
181
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 86</span>
|
182
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">input</span>)
|
183
|
+
<span class="ruby-identifier">src</span> = <span class="ruby-value str">"_buf = [];"</span> <span class="ruby-comment cmt"># preamble</span>
|
184
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-value">0</span>
|
185
|
+
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">EMBEDDED_PATTERN</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lspace</span>, <span class="ruby-identifier">stmtcode</span>, <span class="ruby-identifier">rspace</span>, <span class="ruby-identifier">indicator</span>, <span class="ruby-identifier">exprcode</span><span class="ruby-operator">|</span>
|
186
|
+
<span class="ruby-identifier">match</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>
|
187
|
+
<span class="ruby-identifier">index</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-value">0</span>)
|
188
|
+
<span class="ruby-identifier">text</span> = <span class="ruby-identifier">input</span>[<span class="ruby-identifier">pos</span>, <span class="ruby-identifier">index</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">pos</span>]
|
189
|
+
<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">match</span>.<span class="ruby-identifier">end</span>(<span class="ruby-value">0</span>)
|
190
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stmtcode</span> <span class="ruby-comment cmt"># <?rb ... ?></span>
|
191
|
+
<span class="ruby-identifier">code</span> = <span class="ruby-identifier">stmtcode</span>
|
192
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << '"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_text</span>(<span class="ruby-identifier">text</span>) <span class="ruby-operator"><<</span> <span class="ruby-value str">"';"</span>
|
193
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">rspace</span>
|
194
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{lspace}#{code}#{rspace}"</span>
|
195
|
+
<span class="ruby-keyword kw">else</span>
|
196
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" _buf << '#{lspace}';"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lspace</span>
|
197
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">";"</span>
|
198
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" _buf << '#{rspace}';"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rspace</span>
|
199
|
+
<span class="ruby-keyword kw">end</span>
|
200
|
+
<span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt"># ${...}, $!{...}</span>
|
201
|
+
<span class="ruby-identifier">code</span> = <span class="ruby-identifier">exprcode</span>
|
202
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">indicator</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">indicator</span>.<span class="ruby-identifier">empty?</span>
|
203
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" _buf << #{@escape}("</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">");"</span>
|
204
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">indicator</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'!'</span>
|
205
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << ("</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">").to_s;"</span>
|
206
|
+
<span class="ruby-keyword kw">end</span>
|
207
|
+
<span class="ruby-keyword kw">end</span>
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
209
|
+
<span class="ruby-identifier">rest</span> = <span class="ruby-identifier">$'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">input</span>
|
210
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _buf << '"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">escape_text</span>(<span class="ruby-identifier">rest</span>) <span class="ruby-operator"><<</span> <span class="ruby-value str">"';"</span>
|
211
|
+
<span class="ruby-identifier">src</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n_buf.join\n"</span> <span class="ruby-comment cmt"># postamble</span>
|
212
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">src</span>
|
213
|
+
<span class="ruby-keyword kw">end</span>
|
214
|
+
</pre>
|
215
|
+
</div>
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
|
219
|
+
<div id="method-M000047" class="method-detail">
|
220
|
+
<a name="M000047"></a>
|
221
|
+
|
222
|
+
<div class="method-heading">
|
223
|
+
<a href="#M000047" class="method-signature">
|
224
|
+
<span class="method-name">escape_text</span><span class="method-args">(text)</span>
|
225
|
+
</a>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<div class="method-description">
|
229
|
+
<p><a class="source-toggle" href="#"
|
230
|
+
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
231
|
+
<div class="method-source-code" id="M000047-source">
|
232
|
+
<pre>
|
233
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 119</span>
|
234
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_text</span>(<span class="ruby-identifier">text</span>)
|
235
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/['\\]/</span>, <span class="ruby-value str">'\\\\\&'</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">text</span>
|
236
|
+
<span class="ruby-keyword kw">end</span>
|
237
|
+
</pre>
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div id="method-M000049" class="method-detail">
|
243
|
+
<a name="M000049"></a>
|
244
|
+
|
245
|
+
<div class="method-heading">
|
246
|
+
<a href="#M000049" class="method-signature">
|
247
|
+
<span class="method-name">evaluate</span><span class="method-args">(context=Object.new)</span>
|
248
|
+
</a>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
<div class="method-description">
|
252
|
+
<p><a class="source-toggle" href="#"
|
253
|
+
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
254
|
+
<div class="method-source-code" id="M000049-source">
|
255
|
+
<pre>
|
256
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 127</span>
|
257
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">context</span>=<span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>)
|
258
|
+
<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>)
|
259
|
+
<span class="ruby-identifier">obj</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
260
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{k}"</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword kw">end</span>
|
261
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-identifier">obj</span>
|
262
|
+
<span class="ruby-keyword kw">end</span>
|
263
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-ivar">@src</span>
|
264
|
+
<span class="ruby-keyword kw">end</span>
|
265
|
+
</pre>
|
266
|
+
</div>
|
267
|
+
</div>
|
268
|
+
</div>
|
269
|
+
|
270
|
+
<div id="method-M000048" class="method-detail">
|
271
|
+
<a name="M000048"></a>
|
272
|
+
|
273
|
+
<div class="method-heading">
|
274
|
+
<a href="#M000048" class="method-signature">
|
275
|
+
<span class="method-name">result</span><span class="method-args">(binding=TOPLEVEL_BINDING)</span>
|
276
|
+
</a>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
<div class="method-description">
|
280
|
+
<p><a class="source-toggle" href="#"
|
281
|
+
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
282
|
+
<div class="method-source-code" id="M000048-source">
|
283
|
+
<pre>
|
284
|
+
<span class="ruby-comment cmt"># File erubis/tiny.rb, line 123</span>
|
285
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>=<span class="ruby-constant">TOPLEVEL_BINDING</span>)
|
286
|
+
<span class="ruby-identifier">eval</span> <span class="ruby-ivar">@src</span>, <span class="ruby-identifier">binding</span>
|
287
|
+
<span class="ruby-keyword kw">end</span>
|
288
|
+
</pre>
|
289
|
+
</div>
|
290
|
+
</div>
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
</div>
|
295
|
+
|
296
|
+
|
297
|
+
</div>
|
298
|
+
|
299
|
+
|
300
|
+
<div id="validator-badges">
|
301
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
302
|
+
</div>
|
303
|
+
|
304
|
+
</body>
|
305
|
+
</html>
|