PageTemplate 2.1.7 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +15 -0
- data/doc/classes/PageTemplate.html +203 -0
- data/doc/classes/PageTemplate.src/M000001.html +18 -0
- data/doc/classes/PageTemplate/BlockCommand.html +230 -0
- data/doc/classes/PageTemplate/BlockCommand.src/M000020.html +18 -0
- data/doc/classes/PageTemplate/BlockCommand.src/M000021.html +18 -0
- data/doc/classes/PageTemplate/BlockCommand.src/M000022.html +18 -0
- data/doc/classes/PageTemplate/BlockCommand.src/M000023.html +21 -0
- data/doc/classes/PageTemplate/BlockCommand.src/M000024.html +18 -0
- data/doc/classes/PageTemplate/CaseCommand.html +252 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000085.html +22 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000086.html +22 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000087.html +19 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000088.html +19 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000089.html +23 -0
- data/doc/classes/PageTemplate/CaseCommand.src/M000090.html +23 -0
- data/doc/classes/PageTemplate/Command.html +199 -0
- data/doc/classes/PageTemplate/Command.src/M000045.html +19 -0
- data/doc/classes/PageTemplate/Command.src/M000046.html +18 -0
- data/doc/classes/PageTemplate/CommentCommand.html +187 -0
- data/doc/classes/PageTemplate/CommentCommand.src/M000028.html +18 -0
- data/doc/classes/PageTemplate/CommentCommand.src/M000029.html +18 -0
- data/doc/classes/PageTemplate/CommentCommand.src/M000030.html +18 -0
- data/doc/classes/PageTemplate/DefaultGlossary.html +121 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.html +232 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.src/M000074.html +18 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.src/M000075.html +18 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.src/M000076.html +20 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.src/M000077.html +22 -0
- data/doc/classes/PageTemplate/DefaultPreprocessor.src/M000078.html +18 -0
- data/doc/classes/PageTemplate/DefineCommand.html +166 -0
- data/doc/classes/PageTemplate/DefineCommand.src/M000079.html +19 -0
- data/doc/classes/PageTemplate/DefineCommand.src/M000080.html +19 -0
- data/doc/classes/PageTemplate/FileSource.html +222 -0
- data/doc/classes/PageTemplate/FileSource.src/M000016.html +28 -0
- data/doc/classes/PageTemplate/FileSource.src/M000017.html +32 -0
- data/doc/classes/PageTemplate/FileSource.src/M000018.html +20 -0
- data/doc/classes/PageTemplate/FileSource.src/M000019.html +30 -0
- data/doc/classes/PageTemplate/FilterCommand.html +181 -0
- data/doc/classes/PageTemplate/FilterCommand.src/M000065.html +20 -0
- data/doc/classes/PageTemplate/FilterCommand.src/M000066.html +18 -0
- data/doc/classes/PageTemplate/FilterCommand.src/M000067.html +29 -0
- data/doc/classes/PageTemplate/HTGlossary.html +113 -0
- data/doc/classes/PageTemplate/IfCommand.html +261 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000059.html +24 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000060.html +22 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000061.html +19 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000062.html +20 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000063.html +22 -0
- data/doc/classes/PageTemplate/IfCommand.src/M000064.html +36 -0
- data/doc/classes/PageTemplate/IncludeCommand.html +203 -0
- data/doc/classes/PageTemplate/IncludeCommand.src/M000039.html +18 -0
- data/doc/classes/PageTemplate/IncludeCommand.src/M000040.html +18 -0
- data/doc/classes/PageTemplate/IncludeCommand.src/M000041.html +35 -0
- data/doc/classes/PageTemplate/LoopCommand.html +260 -0
- data/doc/classes/PageTemplate/LoopCommand.src/M000011.html +24 -0
- data/doc/classes/PageTemplate/LoopCommand.src/M000012.html +20 -0
- data/doc/classes/PageTemplate/LoopCommand.src/M000013.html +22 -0
- data/doc/classes/PageTemplate/LoopCommand.src/M000014.html +77 -0
- data/doc/classes/PageTemplate/LoopCommand.src/M000015.html +21 -0
- data/doc/classes/PageTemplate/Namespace.html +163 -0
- data/doc/classes/PageTemplate/Namespace.src/M000057.html +20 -0
- data/doc/classes/PageTemplate/Namespace.src/M000058.html +22 -0
- data/doc/classes/PageTemplate/NamespaceItem.html +333 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000002.html +18 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000004.html +19 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000006.html +84 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000008.html +18 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000009.html +22 -0
- data/doc/classes/PageTemplate/NamespaceItem.src/M000010.html +31 -0
- data/doc/classes/PageTemplate/Parser.html +369 -0
- data/doc/classes/PageTemplate/Parser.src/M000031.html +18 -0
- data/doc/classes/PageTemplate/Parser.src/M000032.html +32 -0
- data/doc/classes/PageTemplate/Parser.src/M000033.html +18 -0
- data/doc/classes/PageTemplate/Parser.src/M000034.html +30 -0
- data/doc/classes/PageTemplate/Parser.src/M000035.html +66 -0
- data/doc/classes/PageTemplate/Parser.src/M000036.html +18 -0
- data/doc/classes/PageTemplate/Parser.src/M000037.html +18 -0
- data/doc/classes/PageTemplate/Parser.src/M000038.html +19 -0
- data/doc/classes/PageTemplate/Preprocessor.html +123 -0
- data/doc/classes/PageTemplate/Source.html +165 -0
- data/doc/classes/PageTemplate/Source.src/M000055.html +18 -0
- data/doc/classes/PageTemplate/Source.src/M000056.html +18 -0
- data/doc/classes/PageTemplate/StackableCommand.html +205 -0
- data/doc/classes/PageTemplate/StackableCommand.src/M000081.html +17 -0
- data/doc/classes/PageTemplate/StackableCommand.src/M000082.html +18 -0
- data/doc/classes/PageTemplate/StackableCommand.src/M000083.html +18 -0
- data/doc/classes/PageTemplate/StackableCommand.src/M000084.html +18 -0
- data/doc/classes/PageTemplate/StringSource.html +163 -0
- data/doc/classes/PageTemplate/StringSource.src/M000053.html +23 -0
- data/doc/classes/PageTemplate/StringSource.src/M000054.html +18 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.html +263 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000047.html +22 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000048.html +24 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000049.html +18 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000050.html +21 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000051.html +21 -0
- data/doc/classes/PageTemplate/SyntaxGlossary.src/M000052.html +22 -0
- data/doc/classes/PageTemplate/Template.html +208 -0
- data/doc/classes/PageTemplate/Template.src/M000071.html +19 -0
- data/doc/classes/PageTemplate/Template.src/M000072.html +18 -0
- data/doc/classes/PageTemplate/Template.src/M000073.html +29 -0
- data/doc/classes/PageTemplate/TextCommand.html +185 -0
- data/doc/classes/PageTemplate/TextCommand.src/M000068.html +18 -0
- data/doc/classes/PageTemplate/TextCommand.src/M000069.html +18 -0
- data/doc/classes/PageTemplate/TextCommand.src/M000070.html +18 -0
- data/doc/classes/PageTemplate/UnknownCommand.html +191 -0
- data/doc/classes/PageTemplate/UnknownCommand.src/M000025.html +24 -0
- data/doc/classes/PageTemplate/UnknownCommand.src/M000026.html +18 -0
- data/doc/classes/PageTemplate/UnknownCommand.src/M000027.html +18 -0
- data/doc/classes/PageTemplate/ValueCommand.html +206 -0
- data/doc/classes/PageTemplate/ValueCommand.src/M000042.html +19 -0
- data/doc/classes/PageTemplate/ValueCommand.src/M000043.html +27 -0
- data/doc/classes/PageTemplate/ValueCommand.src/M000044.html +21 -0
- data/doc/created.rid +1 -0
- data/doc/files/README_txt.html +225 -0
- data/doc/files/lib/PageTemplate/case_rb.html +115 -0
- data/doc/files/lib/PageTemplate/commands_rb.html +111 -0
- data/doc/files/lib/PageTemplate/htglossary_rb.html +110 -0
- data/doc/files/lib/PageTemplate/parser_rb.html +111 -0
- data/doc/files/lib/PageTemplate_rb.html +139 -0
- data/doc/fr_class_index.html +52 -0
- data/doc/fr_file_index.html +32 -0
- data/doc/fr_method_index.html +116 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/PageTemplate.rb +1 -1
- data/lib/PageTemplate/commands.rb +49 -5
- data/lib/PageTemplate/parser.rb +57 -10
- data/tdata/include.txt +3 -0
- data/tdata/include2.txt +3 -0
- data/tdata/variable.txt +1 -0
- data/test.rb +83 -6
- metadata +159 -2
@@ -0,0 +1,18 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>new (PageTemplate::IncludeCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 518</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">value</span>)
|
15
|
+
<span class="ruby-ivar">@value</span> = <span class="ruby-identifier">value</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>to_s (PageTemplate::IncludeCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 521</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
15
|
+
<span class="ruby-node">"[ Include: #{@value} ]"</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>output (PageTemplate::IncludeCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 531</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>)
|
15
|
+
<span class="ruby-comment cmt"># We don't use parser.compile because we need to know when something</span>
|
16
|
+
<span class="ruby-comment cmt"># doesn't exist.</span>
|
17
|
+
<span class="ruby-identifier">parser</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">parser</span>
|
18
|
+
<span class="ruby-identifier">fn</span> = <span class="ruby-ivar">@value</span>
|
19
|
+
<span class="ruby-identifier">body</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">source</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">fn</span>)
|
20
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">body</span>
|
21
|
+
<span class="ruby-identifier">fn</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@value</span>)
|
22
|
+
<span class="ruby-identifier">body</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">source</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">fn</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fn</span>
|
23
|
+
<span class="ruby-keyword kw">end</span>
|
24
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Command</span>)
|
25
|
+
<span class="ruby-identifier">body</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>)
|
26
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">body</span>
|
27
|
+
<span class="ruby-identifier">cmds</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">body</span>)
|
28
|
+
<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">source</span>.<span class="ruby-identifier">cache</span>(<span class="ruby-identifier">fn</span>,<span class="ruby-identifier">cmds</span>)
|
29
|
+
<span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>)
|
30
|
+
<span class="ruby-keyword kw">else</span>
|
31
|
+
<span class="ruby-node">"[ Template '#{fn}' not found ]"</span>
|
32
|
+
<span class="ruby-keyword kw">end</span>
|
33
|
+
<span class="ruby-keyword kw">end</span></pre>
|
34
|
+
</body>
|
35
|
+
</html>
|
@@ -0,0 +1,260 @@
|
|
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: PageTemplate::LoopCommand</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">PageTemplate::LoopCommand</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/PageTemplate/commands_rb.html">
|
59
|
+
lib/PageTemplate/commands.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="StackableCommand.html">
|
69
|
+
StackableCommand
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
<a href="LoopCommand.html">LoopCommand</a> is a <a
|
86
|
+
href="StackableCommand.html">StackableCommand</a>. It requires an opening:
|
87
|
+
</p>
|
88
|
+
<dl>
|
89
|
+
<dt>% if variable %</dt><dd>or [% unless variable %].
|
90
|
+
|
91
|
+
</dd>
|
92
|
+
</dl>
|
93
|
+
<p>
|
94
|
+
<tt>variable</tt> is fetched from the namespace.
|
95
|
+
</p>
|
96
|
+
<p>
|
97
|
+
On execution, if <tt>variable</tt> is true, and non-empty, then @commands
|
98
|
+
is printed once with each item in the list placed in its own namespace and
|
99
|
+
passed to the loop commands. (a list is defined as an object that responds
|
100
|
+
to :map)
|
101
|
+
</p>
|
102
|
+
<p>
|
103
|
+
If <tt>variable</tt> is true, but does not respond to :map, then the list
|
104
|
+
is called once
|
105
|
+
</p>
|
106
|
+
<dl>
|
107
|
+
<dt>% else %</dt><dd>may be specified, modifying <a href="LoopCommand.html">LoopCommand</a> to
|
108
|
+
print out
|
109
|
+
|
110
|
+
</dd>
|
111
|
+
</dl>
|
112
|
+
<p>
|
113
|
+
@elseCommands in case <tt>variable</tt> is false, or empty.
|
114
|
+
</p>
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<div id="method-list">
|
122
|
+
<h3 class="section-bar">Methods</h3>
|
123
|
+
|
124
|
+
<div class="name-list">
|
125
|
+
<a href="#M000013">add</a>
|
126
|
+
<a href="#M000012">else</a>
|
127
|
+
<a href="#M000011">new</a>
|
128
|
+
<a href="#M000014">output</a>
|
129
|
+
<a href="#M000015">to_s</a>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
<!-- if includes -->
|
137
|
+
|
138
|
+
<div id="section">
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<!-- if method_list -->
|
148
|
+
<div id="methods">
|
149
|
+
<h3 class="section-bar">Public Class methods</h3>
|
150
|
+
|
151
|
+
<div id="method-M000011" class="method-detail">
|
152
|
+
<a name="M000011"></a>
|
153
|
+
|
154
|
+
<div class="method-heading">
|
155
|
+
<a href="LoopCommand.src/M000011.html" target="Code" class="method-signature"
|
156
|
+
onclick="popupCode('LoopCommand.src/M000011.html');return false;">
|
157
|
+
<span class="method-name">new</span><span class="method-args">(called_as, value, iterators)</span>
|
158
|
+
</a>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div class="method-description">
|
162
|
+
<dl>
|
163
|
+
<dt>% in variable %</dt><dd>or [% loop variable %]
|
164
|
+
|
165
|
+
</dd>
|
166
|
+
</dl>
|
167
|
+
<p>
|
168
|
+
Or [% in variable: name %]
|
169
|
+
</p>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
174
|
+
|
175
|
+
<div id="method-M000013" class="method-detail">
|
176
|
+
<a name="M000013"></a>
|
177
|
+
|
178
|
+
<div class="method-heading">
|
179
|
+
<a href="LoopCommand.src/M000013.html" target="Code" class="method-signature"
|
180
|
+
onclick="popupCode('LoopCommand.src/M000013.html');return false;">
|
181
|
+
<span class="method-name">add</span><span class="method-args">(command)</span>
|
182
|
+
</a>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div class="method-description">
|
186
|
+
<p>
|
187
|
+
adds to @commands for the loop, or @elseCommands if ‘else’ has
|
188
|
+
been passed.
|
189
|
+
</p>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div id="method-M000012" class="method-detail">
|
194
|
+
<a name="M000012"></a>
|
195
|
+
|
196
|
+
<div class="method-heading">
|
197
|
+
<a href="LoopCommand.src/M000012.html" target="Code" class="method-signature"
|
198
|
+
onclick="popupCode('LoopCommand.src/M000012.html');return false;">
|
199
|
+
<span class="method-name">else</span><span class="method-args">()</span>
|
200
|
+
</a>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div class="method-description">
|
204
|
+
<p>
|
205
|
+
An ‘else’ defines a list of commands to call when the loop is
|
206
|
+
empty.
|
207
|
+
</p>
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div id="method-M000014" class="method-detail">
|
212
|
+
<a name="M000014"></a>
|
213
|
+
|
214
|
+
<div class="method-heading">
|
215
|
+
<a href="LoopCommand.src/M000014.html" target="Code" class="method-signature"
|
216
|
+
onclick="popupCode('LoopCommand.src/M000014.html');return false;">
|
217
|
+
<span class="method-name">output</span><span class="method-args">(namespace)</span>
|
218
|
+
</a>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div class="method-description">
|
222
|
+
<p>
|
223
|
+
If <tt>variable</tt> is true, and non-empty, then @commands is printed once
|
224
|
+
with each item in the list placed in its own namespace and passed to the
|
225
|
+
loop commands. (a list is defined as an object that responds to :map)
|
226
|
+
</p>
|
227
|
+
<p>
|
228
|
+
If <tt>variable</tt> is true, but does not respond to :map, then the list
|
229
|
+
is called once
|
230
|
+
</p>
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div id="method-M000015" class="method-detail">
|
235
|
+
<a name="M000015"></a>
|
236
|
+
|
237
|
+
<div class="method-heading">
|
238
|
+
<a href="LoopCommand.src/M000015.html" target="Code" class="method-signature"
|
239
|
+
onclick="popupCode('LoopCommand.src/M000015.html');return false;">
|
240
|
+
<span class="method-name">to_s</span><span class="method-args">()</span>
|
241
|
+
</a>
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div class="method-description">
|
245
|
+
</div>
|
246
|
+
</div>
|
247
|
+
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
</div>
|
253
|
+
|
254
|
+
|
255
|
+
<div id="validator-badges">
|
256
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</body>
|
260
|
+
</html>
|
@@ -0,0 +1,24 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>new (PageTemplate::LoopCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 402</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">called_as</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">iterators</span>)
|
15
|
+
<span class="ruby-ivar">@called_as</span> = <span class="ruby-identifier">called_as</span>
|
16
|
+
<span class="ruby-ivar">@value</span> = <span class="ruby-identifier">value</span>
|
17
|
+
<span class="ruby-ivar">@iterators</span> = <span class="ruby-identifier">iterators</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\s+/</span>,<span class="ruby-value str">' '</span>).<span class="ruby-identifier">split</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">iterators</span>
|
18
|
+
<span class="ruby-ivar">@switched</span> = <span class="ruby-keyword kw">false</span>
|
19
|
+
<span class="ruby-ivar">@commands</span> = <span class="ruby-constant">BlockCommand</span>.<span class="ruby-identifier">new</span>
|
20
|
+
<span class="ruby-ivar">@elseCommands</span> = <span class="ruby-constant">BlockCommand</span>.<span class="ruby-identifier">new</span>
|
21
|
+
<span class="ruby-ivar">@in_else</span> = <span class="ruby-keyword kw">false</span>
|
22
|
+
<span class="ruby-keyword kw">end</span></pre>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>else (PageTemplate::LoopCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 413</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">else</span>
|
15
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"More than one 'else' to IfCommand"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@switched</span>
|
16
|
+
<span class="ruby-ivar">@in_else</span> = <span class="ruby-operator">!</span> <span class="ruby-ivar">@in_else</span>
|
17
|
+
<span class="ruby-ivar">@switched</span> = <span class="ruby-keyword kw">true</span>
|
18
|
+
<span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>add (PageTemplate::LoopCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 420</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">command</span>)
|
15
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@in_else</span>
|
16
|
+
<span class="ruby-ivar">@commands</span>.<span class="ruby-identifier">add</span> <span class="ruby-identifier">command</span>
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-ivar">@elseCommands</span>.<span class="ruby-identifier">add</span> <span class="ruby-identifier">command</span>
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-keyword kw">end</span></pre>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,77 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>output (PageTemplate::LoopCommand)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/PageTemplate/commands.rb, line 434</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>)
|
15
|
+
|
16
|
+
<span class="ruby-identifier">vals</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@value</span>)
|
17
|
+
<span class="ruby-identifier">ns</span> = <span class="ruby-keyword kw">nil</span>
|
18
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@elseCommands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">vals</span>
|
19
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:map</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:length</span>)
|
20
|
+
<span class="ruby-identifier">vals</span> = [<span class="ruby-identifier">vals</span>]
|
21
|
+
<span class="ruby-keyword kw">end</span>
|
22
|
+
|
23
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@elseCommands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">empty?</span>
|
24
|
+
|
25
|
+
<span class="ruby-comment cmt"># Unfortunately, no "map_with_index"</span>
|
26
|
+
<span class="ruby-identifier">len</span> = <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">length</span>
|
27
|
+
<span class="ruby-identifier">i</span> = <span class="ruby-value">1</span>
|
28
|
+
<span class="ruby-identifier">odd</span> = <span class="ruby-keyword kw">true</span>
|
29
|
+
<span class="ruby-identifier">ns</span> = <span class="ruby-constant">Namespace</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">namespace</span>)
|
30
|
+
|
31
|
+
<span class="ruby-comment cmt"># Print the output of all the objects joined together.</span>
|
32
|
+
<span class="ruby-keyword kw">case</span>
|
33
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-ivar">@iterators</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@iterators</span>.<span class="ruby-identifier">empty?</span>
|
34
|
+
<span class="ruby-identifier">vals</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
|
35
|
+
<span class="ruby-identifier">ns</span>.<span class="ruby-identifier">clear</span>
|
36
|
+
<span class="ruby-identifier">ns</span>.<span class="ruby-identifier">object</span> = <span class="ruby-identifier">item</span>
|
37
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__FIRST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
38
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__LAST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">len</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
39
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__ODD__'</span>] = <span class="ruby-identifier">odd</span>
|
40
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__INDEX__'</span>] = <span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
41
|
+
<span class="ruby-identifier">odd</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">odd</span>
|
42
|
+
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
43
|
+
<span class="ruby-ivar">@commands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">ns</span>)
|
44
|
+
}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">''</span>)
|
45
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-ivar">@iterators</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
46
|
+
<span class="ruby-identifier">iterator</span> = <span class="ruby-ivar">@iterators</span>[<span class="ruby-value">0</span>]
|
47
|
+
<span class="ruby-identifier">vals</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
|
48
|
+
<span class="ruby-identifier">ns</span>.<span class="ruby-identifier">clear_cache</span>
|
49
|
+
<span class="ruby-comment cmt"># We have an explicit iterator - don't set an object for it.</span>
|
50
|
+
<span class="ruby-comment cmt"># ns.object = item</span>
|
51
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__FIRST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
52
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__LAST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">len</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
53
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__ODD__'</span>] = <span class="ruby-identifier">odd</span>
|
54
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__INDEX__'</span>] = <span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
55
|
+
<span class="ruby-identifier">odd</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">odd</span>
|
56
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-identifier">iterator</span>] = <span class="ruby-identifier">item</span>
|
57
|
+
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
58
|
+
<span class="ruby-ivar">@commands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">ns</span>)
|
59
|
+
}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">''</span>)
|
60
|
+
<span class="ruby-keyword kw">else</span>
|
61
|
+
<span class="ruby-identifier">vals</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">list</span><span class="ruby-operator">|</span>
|
62
|
+
<span class="ruby-identifier">ns</span>.<span class="ruby-identifier">clear_cache</span>
|
63
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__FIRST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
64
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__LAST__'</span>] = (<span class="ruby-identifier">i</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">len</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
65
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__ODD__'</span>] = <span class="ruby-identifier">odd</span>
|
66
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-value str">'__INDEX__'</span>] = <span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
67
|
+
<span class="ruby-ivar">@iterators</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">iterator</span>,<span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
68
|
+
<span class="ruby-identifier">ns</span>[<span class="ruby-identifier">iterator</span>] = <span class="ruby-identifier">list</span>[<span class="ruby-identifier">index</span>]
|
69
|
+
<span class="ruby-keyword kw">end</span>
|
70
|
+
<span class="ruby-identifier">odd</span> = <span class="ruby-operator">!</span> <span class="ruby-identifier">odd</span>
|
71
|
+
<span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
72
|
+
<span class="ruby-ivar">@commands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">ns</span>)
|
73
|
+
}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">''</span>)
|
74
|
+
<span class="ruby-keyword kw">end</span>
|
75
|
+
<span class="ruby-keyword kw">end</span></pre>
|
76
|
+
</body>
|
77
|
+
</html>
|