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
data/lib/PageTemplate.rb
CHANGED
@@ -84,7 +84,7 @@ class PageTemplate
|
|
84
84
|
# branch in the logic: such as If, Loop, etcetera.
|
85
85
|
#
|
86
86
|
# Any child that wants to do more than stand alone must inherit from
|
87
|
-
# StackableCommand.
|
87
|
+
# StackableCommand. We recommend setting @called_as, so
|
88
88
|
# all of StackableCommand's ways of closing blocks work.
|
89
89
|
class StackableCommand < Command
|
90
90
|
@modifier = nil
|
@@ -209,6 +209,50 @@ class PageTemplate
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
+
# DefineCommand will set a variable within the enclosing namespace
|
213
|
+
class DefineCommand < Command
|
214
|
+
def initialize(name, value)
|
215
|
+
@name = name
|
216
|
+
@value = value
|
217
|
+
end
|
218
|
+
|
219
|
+
# Doesn't return any output
|
220
|
+
def output(namespace)
|
221
|
+
namespace[@name] = @value
|
222
|
+
return
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# FilterCommand filters its block through a preprocessor
|
227
|
+
# [% filter :processor %]text[% end %]
|
228
|
+
class FilterCommand < StackableCommand
|
229
|
+
@closer = :end
|
230
|
+
def initialize(filter)
|
231
|
+
@called_as = "filter"
|
232
|
+
@processor = filter
|
233
|
+
@text = []
|
234
|
+
end
|
235
|
+
|
236
|
+
def add(line)
|
237
|
+
@text.push(line)
|
238
|
+
end
|
239
|
+
|
240
|
+
def output(namespace=nil)
|
241
|
+
parser = namespace.parser if namespace
|
242
|
+
parser = Parser.recent_parser unless parser
|
243
|
+
namespace ||= parser
|
244
|
+
preprocessor = parser.preprocessor
|
245
|
+
processor = @processor || parser.default_processor
|
246
|
+
text = ""
|
247
|
+
@text.each { |c| text += c.output(namespace) }
|
248
|
+
if preprocessor.respond_to?(processor)
|
249
|
+
preprocessor.send(processor, text)
|
250
|
+
else
|
251
|
+
"[ ValueCommand: unknown preprocessor #{@processor} ]"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
212
256
|
# ValueCommand will print out a variable name, possibly passing its
|
213
257
|
# value through a preprocessor.
|
214
258
|
#
|
@@ -217,8 +261,8 @@ class PageTemplate
|
|
217
261
|
# +variable+ is first plucked out of the Namespace,
|
218
262
|
#
|
219
263
|
# The to_s of the output from Namespace#get is passed through
|
220
|
-
# parser's preprocessor. If :processor is defined, then
|
221
|
-
# parser.preprocessor.send(:processor,body) is called
|
264
|
+
# parser's preprocessor. If :processor is defined, then
|
265
|
+
# parser.preprocessor.send(:processor,body) is called. This allows the
|
222
266
|
# designer to choose a particular format for the output. If
|
223
267
|
# :processor is not given, then parser's default processor is used.
|
224
268
|
class ValueCommand < Command
|
@@ -498,8 +542,8 @@ class PageTemplate
|
|
498
542
|
body.output(namespace)
|
499
543
|
elsif body
|
500
544
|
cmds = parser.parse(body)
|
501
|
-
|
502
|
-
|
545
|
+
parser.source.cache(fn,cmds)
|
546
|
+
cmds.output(namespace)
|
503
547
|
else
|
504
548
|
"[ Template '#{fn}' not found ]"
|
505
549
|
end
|
data/lib/PageTemplate/parser.rb
CHANGED
@@ -160,11 +160,21 @@ class PageTemplate
|
|
160
160
|
|
161
161
|
class Namespace
|
162
162
|
include NamespaceItem
|
163
|
+
|
163
164
|
def initialize(parent=nil,object=nil)
|
164
165
|
@values = Hash.new
|
165
166
|
@parent = parent
|
166
167
|
@object = object
|
167
168
|
end
|
169
|
+
|
170
|
+
# Create a new top-level Namespace with a Hash-like object
|
171
|
+
def Namespace.construct_from(arg)
|
172
|
+
ns = Namespace.new()
|
173
|
+
arg.each { |k, v|
|
174
|
+
ns[k] = v
|
175
|
+
}
|
176
|
+
return ns
|
177
|
+
end
|
168
178
|
end
|
169
179
|
|
170
180
|
# A Source is a source from which templates are drawn.
|
@@ -172,14 +182,32 @@ class PageTemplate
|
|
172
182
|
# Source#get(name) must return the body of the template that is to
|
173
183
|
# be parsed, or nil if it doesn't exist.
|
174
184
|
class Source
|
185
|
+
|
175
186
|
def initialize(args = {})
|
176
187
|
@args = args
|
177
188
|
end
|
178
|
-
|
189
|
+
|
190
|
+
def get(name=nil)
|
179
191
|
name
|
180
192
|
end
|
181
193
|
end
|
182
194
|
|
195
|
+
# A StringSource is created with a raw string, which is returned on any
|
196
|
+
# call to 'get'.
|
197
|
+
class StringSource < Source
|
198
|
+
def initialize(args)
|
199
|
+
if args.class == String
|
200
|
+
@source = args
|
201
|
+
else
|
202
|
+
@args = args
|
203
|
+
@source = args["source"]
|
204
|
+
end
|
205
|
+
end
|
206
|
+
def get()
|
207
|
+
return @source
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
183
211
|
# FileSource provides access to files within the 'include_paths'
|
184
212
|
# argument.
|
185
213
|
#
|
@@ -212,15 +240,15 @@ class PageTemplate
|
|
212
240
|
fn = get_filename(name)
|
213
241
|
begin
|
214
242
|
case
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
243
|
+
when fn.nil?
|
244
|
+
nil
|
245
|
+
when @cache.has_key?(fn) && (@mtime[fn] > File.mtime(fn).to_i)
|
246
|
+
cmds = @cache[fn]
|
247
|
+
cmds.clear_cache
|
248
|
+
cmds
|
249
|
+
else
|
250
|
+
IO.read(fn)
|
251
|
+
end
|
224
252
|
rescue Exception => er
|
225
253
|
return "[ Unable to open file #{fn} because of #{er.message} ]"
|
226
254
|
end
|
@@ -231,6 +259,12 @@ class PageTemplate
|
|
231
259
|
@mtime[fn] = Time.now.to_i
|
232
260
|
end
|
233
261
|
def get_filename(file)
|
262
|
+
# Check for absolute filepaths
|
263
|
+
if file == File.expand_path(file)
|
264
|
+
if File.exists?(file)
|
265
|
+
return file
|
266
|
+
end
|
267
|
+
end
|
234
268
|
file = file.gsub(/\.\.\//,'')
|
235
269
|
@paths.each do |path|
|
236
270
|
fn = File.join(path,file)
|
@@ -327,6 +361,14 @@ class PageTemplate
|
|
327
361
|
CommentCommand.new(match[1])
|
328
362
|
}
|
329
363
|
|
364
|
+
define(/^define (\w+)\s+?(.+)$/i) { |match|
|
365
|
+
DefineCommand.new(match[1], match[2])
|
366
|
+
}
|
367
|
+
|
368
|
+
define(/^filter :(\w+)$/i) { |match|
|
369
|
+
FilterCommand.new(match[1])
|
370
|
+
}
|
371
|
+
|
330
372
|
define(/^(if|unless) ((\w+)(\.\w+\??)*)$/i) { |match|
|
331
373
|
# Called_As, Value
|
332
374
|
IfCommand.new(match[1],match[2])
|
@@ -481,6 +523,11 @@ class PageTemplate
|
|
481
523
|
@@recent_parser = self
|
482
524
|
@args = args # For sub-commands
|
483
525
|
@parent = args['namespace'] || nil
|
526
|
+
if @parent
|
527
|
+
unless @parent.is_a? Namespace then
|
528
|
+
@parent = Namespace.construct_from(args['namespace'])
|
529
|
+
end
|
530
|
+
end
|
484
531
|
@glossary = args['glossary'] || DefaultGlossary
|
485
532
|
@preprocessor = args['preprocessor'] || DefaultPreprocessor
|
486
533
|
@default_processor = args['default_processor'] || :unescaped
|
data/tdata/include.txt
ADDED
data/tdata/include2.txt
ADDED
data/tdata/variable.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Hello, [%var name %]!
|
data/test.rb
CHANGED
@@ -159,12 +159,29 @@ module TestPageTemplate
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
+
class TestDefine < Test::Unit::TestCase
|
163
|
+
def setup
|
164
|
+
@@p = PageTemplate::Parser.new('empty_is_true' => false)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_output
|
168
|
+
template = @@p.parse("[%define zero 0%]Zero is [%var zero%]")
|
169
|
+
assert_equal("Zero is 0", template.output,
|
170
|
+
"define command allows you to set values in a template")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
162
174
|
class TestFileSource < Test::Unit::TestCase
|
163
175
|
def setup
|
164
176
|
@@args = {}
|
165
177
|
@@fs = PageTemplate::FileSource.new(@@args)
|
166
|
-
|
167
|
-
|
178
|
+
# Construct an absolute path, whatever it looks like on our platform
|
179
|
+
require 'pathname'
|
180
|
+
cwd = Dir.getwd
|
181
|
+
directory = "tdata"
|
182
|
+
file = "dummy.txt"
|
183
|
+
@@filename = File.join(directory, file)
|
184
|
+
@@location = File.join(cwd, directory, file)
|
168
185
|
@@text = IO.read(@@location)
|
169
186
|
end
|
170
187
|
|
@@ -210,15 +227,29 @@ module TestPageTemplate
|
|
210
227
|
end
|
211
228
|
end
|
212
229
|
|
230
|
+
class TestFilterCommand < Test::Unit::TestCase
|
231
|
+
def setup
|
232
|
+
@@p = PageTemplate::Parser.new()
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_filter
|
236
|
+
source = "[%filter :reverse %]foo[%end%]"
|
237
|
+
assert_equal("oof", @@p.parse(source).output,
|
238
|
+
"FilterCommands can be used to filter raw template text.")
|
239
|
+
@@p["f"] = "boy"
|
240
|
+
source = "[%filter :reverse %][%var f%][%end%]"
|
241
|
+
assert_equal("yob", @@p.parse(source).output,
|
242
|
+
"Commands in a FilterCommand are parsed before filtering")
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
213
246
|
class TestIfCommand < Test::Unit::TestCase
|
214
247
|
def setup
|
215
|
-
parser = PageTemplate::Parser.new()
|
216
248
|
@@if = PageTemplate::IfCommand.new("if", "flag")
|
217
249
|
@@unless = PageTemplate::IfCommand.new("unless", "flag")
|
218
250
|
end
|
219
251
|
|
220
252
|
def test_initialize
|
221
|
-
parser = PageTemplate::Parser.new
|
222
253
|
good_1 = "if flag"
|
223
254
|
good_2 = "unless flag"
|
224
255
|
bad_1 = "heck no"
|
@@ -299,13 +330,29 @@ module TestPageTemplate
|
|
299
330
|
end
|
300
331
|
|
301
332
|
class TestIncludeCommand < Test::Unit::TestCase
|
302
|
-
def
|
333
|
+
def test_simple_output
|
303
334
|
parser = PageTemplate::Parser.new()
|
304
|
-
parser['dummy'] =
|
335
|
+
parser['dummy'] = File.join("tdata", "dummy.txt")
|
305
336
|
i = PageTemplate::IncludeCommand.new('dummy')
|
306
337
|
parser.load('tdata/dummy.txt')
|
307
338
|
assert_equal(parser.output, i.output(parser))
|
308
339
|
end
|
340
|
+
|
341
|
+
def test_include_template
|
342
|
+
pt = PageTemplate::Parser.new("include_path" => "tdata/")
|
343
|
+
pt.load("include.txt")
|
344
|
+
pt["file"] = "variable.txt"
|
345
|
+
pt["name"] = "Phil"
|
346
|
+
assert(pt.output =~ /Hello, Phil!/,
|
347
|
+
"Included files are parsed as templates.")
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_include_literal
|
351
|
+
pt = PageTemplate::Parser.new("include_path" => "tdata")
|
352
|
+
pt.load("include2.txt")
|
353
|
+
assert(pt.output =~ /get_filename/,
|
354
|
+
"Include Commands can be handed a filename directly")
|
355
|
+
end
|
309
356
|
end
|
310
357
|
|
311
358
|
class TestLoopCommand < Test::Unit::TestCase
|
@@ -554,6 +601,20 @@ module TestPageTemplate
|
|
554
601
|
assert_equal({}, @@p.args)
|
555
602
|
end
|
556
603
|
|
604
|
+
def test_namespace_arg
|
605
|
+
require 'yaml'
|
606
|
+
ns = PageTemplate::Namespace.new()
|
607
|
+
ns['oompa'] = 'loompa'
|
608
|
+
p = PageTemplate::Parser.new('namespace' => ns)
|
609
|
+
assert_equal('loompa', p['oompa'])
|
610
|
+
p = PageTemplate::Parser.new('namespace' => { 'oompa' => 'loompa' })
|
611
|
+
assert_equal('loompa', p['oompa'])
|
612
|
+
# This assertion is just for my own peace of mind.
|
613
|
+
y = YAML::load({ 'doompity' => 'doo' }.to_yaml)
|
614
|
+
p = PageTemplate::Parser.new('namespace' => y)
|
615
|
+
assert_equal('doo', p['doompity'])
|
616
|
+
end
|
617
|
+
|
557
618
|
def test_clearCommands
|
558
619
|
@@p.clearCommands
|
559
620
|
assert_equal(nil, @@p.commands)
|
@@ -607,6 +668,18 @@ module TestPageTemplate
|
|
607
668
|
end
|
608
669
|
end
|
609
670
|
|
671
|
+
class TestStringSource < Test::Unit::TestCase
|
672
|
+
def test_get
|
673
|
+
str = "John Jacob Jingleheimer Smith"
|
674
|
+
ss = PageTemplate::StringSource.new(str)
|
675
|
+
assert_equal(str, ss.get,
|
676
|
+
"StringSource holds a simple String")
|
677
|
+
ss = PageTemplate::StringSource.new("source" => str)
|
678
|
+
assert_equal(str, ss.get,
|
679
|
+
"StringSource holds a simple String")
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
610
683
|
class TestSyntaxGlossary < Test::Unit::TestCase
|
611
684
|
# Test modifications by gmillam
|
612
685
|
def setup
|
@@ -723,13 +796,16 @@ module TestPageTemplate
|
|
723
796
|
assert_equal('4',w.output(p.namespace))
|
724
797
|
assert_equal('',v.output(p.namespace))
|
725
798
|
end
|
799
|
+
|
726
800
|
def test_raise_on_error
|
727
801
|
p = PageTemplate::Parser.new
|
728
802
|
template = p.parse("[% var foo.bar %]")
|
729
803
|
foo = "hello"
|
804
|
+
|
730
805
|
def foo.bar
|
731
806
|
asdf # method unknown error
|
732
807
|
end
|
808
|
+
|
733
809
|
template["foo"] = foo
|
734
810
|
assert_equal(
|
735
811
|
template.output,
|
@@ -743,6 +819,7 @@ module TestPageTemplate
|
|
743
819
|
rescue Exception => er
|
744
820
|
puts "error: #{er.class}"
|
745
821
|
end
|
822
|
+
|
746
823
|
end
|
747
824
|
end
|
748
825
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: PageTemplate
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.
|
7
|
-
date: 2006-02
|
6
|
+
version: 2.2.0
|
7
|
+
date: 2006-03-02 00:00:00 -08:00
|
8
8
|
summary: A simple templating system for Web sites.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -29,6 +29,7 @@ authors:
|
|
29
29
|
- Brian Wisti
|
30
30
|
files:
|
31
31
|
- Changes
|
32
|
+
- doc
|
32
33
|
- lib
|
33
34
|
- MANIFEST
|
34
35
|
- Rakefile
|
@@ -39,6 +40,159 @@ files:
|
|
39
40
|
- tdata
|
40
41
|
- test-install.rb
|
41
42
|
- test.rb
|
43
|
+
- doc/classes
|
44
|
+
- doc/created.rid
|
45
|
+
- doc/files
|
46
|
+
- doc/fr_class_index.html
|
47
|
+
- doc/fr_file_index.html
|
48
|
+
- doc/fr_method_index.html
|
49
|
+
- doc/index.html
|
50
|
+
- doc/rdoc-style.css
|
51
|
+
- doc/classes/PageTemplate
|
52
|
+
- doc/classes/PageTemplate.html
|
53
|
+
- doc/classes/PageTemplate.src
|
54
|
+
- doc/classes/PageTemplate/BlockCommand.html
|
55
|
+
- doc/classes/PageTemplate/BlockCommand.src
|
56
|
+
- doc/classes/PageTemplate/CaseCommand.html
|
57
|
+
- doc/classes/PageTemplate/CaseCommand.src
|
58
|
+
- doc/classes/PageTemplate/Command.html
|
59
|
+
- doc/classes/PageTemplate/Command.src
|
60
|
+
- doc/classes/PageTemplate/CommentCommand.html
|
61
|
+
- doc/classes/PageTemplate/CommentCommand.src
|
62
|
+
- doc/classes/PageTemplate/DefaultGlossary.html
|
63
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.html
|
64
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src
|
65
|
+
- doc/classes/PageTemplate/DefineCommand.html
|
66
|
+
- doc/classes/PageTemplate/DefineCommand.src
|
67
|
+
- doc/classes/PageTemplate/FileSource.html
|
68
|
+
- doc/classes/PageTemplate/FileSource.src
|
69
|
+
- doc/classes/PageTemplate/FilterCommand.html
|
70
|
+
- doc/classes/PageTemplate/FilterCommand.src
|
71
|
+
- doc/classes/PageTemplate/HTGlossary.html
|
72
|
+
- doc/classes/PageTemplate/IfCommand.html
|
73
|
+
- doc/classes/PageTemplate/IfCommand.src
|
74
|
+
- doc/classes/PageTemplate/IncludeCommand.html
|
75
|
+
- doc/classes/PageTemplate/IncludeCommand.src
|
76
|
+
- doc/classes/PageTemplate/LoopCommand.html
|
77
|
+
- doc/classes/PageTemplate/LoopCommand.src
|
78
|
+
- doc/classes/PageTemplate/Namespace.html
|
79
|
+
- doc/classes/PageTemplate/Namespace.src
|
80
|
+
- doc/classes/PageTemplate/NamespaceItem.html
|
81
|
+
- doc/classes/PageTemplate/NamespaceItem.src
|
82
|
+
- doc/classes/PageTemplate/Parser.html
|
83
|
+
- doc/classes/PageTemplate/Parser.src
|
84
|
+
- doc/classes/PageTemplate/Preprocessor.html
|
85
|
+
- doc/classes/PageTemplate/Source.html
|
86
|
+
- doc/classes/PageTemplate/Source.src
|
87
|
+
- doc/classes/PageTemplate/StackableCommand.html
|
88
|
+
- doc/classes/PageTemplate/StackableCommand.src
|
89
|
+
- doc/classes/PageTemplate/StringSource.html
|
90
|
+
- doc/classes/PageTemplate/StringSource.src
|
91
|
+
- doc/classes/PageTemplate/SyntaxGlossary.html
|
92
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src
|
93
|
+
- doc/classes/PageTemplate/Template.html
|
94
|
+
- doc/classes/PageTemplate/Template.src
|
95
|
+
- doc/classes/PageTemplate/TextCommand.html
|
96
|
+
- doc/classes/PageTemplate/TextCommand.src
|
97
|
+
- doc/classes/PageTemplate/UnknownCommand.html
|
98
|
+
- doc/classes/PageTemplate/UnknownCommand.src
|
99
|
+
- doc/classes/PageTemplate/ValueCommand.html
|
100
|
+
- doc/classes/PageTemplate/ValueCommand.src
|
101
|
+
- doc/classes/PageTemplate/BlockCommand.src/M000020.html
|
102
|
+
- doc/classes/PageTemplate/BlockCommand.src/M000021.html
|
103
|
+
- doc/classes/PageTemplate/BlockCommand.src/M000022.html
|
104
|
+
- doc/classes/PageTemplate/BlockCommand.src/M000023.html
|
105
|
+
- doc/classes/PageTemplate/BlockCommand.src/M000024.html
|
106
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000085.html
|
107
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000086.html
|
108
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000087.html
|
109
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000088.html
|
110
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000089.html
|
111
|
+
- doc/classes/PageTemplate/CaseCommand.src/M000090.html
|
112
|
+
- doc/classes/PageTemplate/Command.src/M000045.html
|
113
|
+
- doc/classes/PageTemplate/Command.src/M000046.html
|
114
|
+
- doc/classes/PageTemplate/CommentCommand.src/M000028.html
|
115
|
+
- doc/classes/PageTemplate/CommentCommand.src/M000029.html
|
116
|
+
- doc/classes/PageTemplate/CommentCommand.src/M000030.html
|
117
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src/M000074.html
|
118
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src/M000075.html
|
119
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src/M000076.html
|
120
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src/M000077.html
|
121
|
+
- doc/classes/PageTemplate/DefaultPreprocessor.src/M000078.html
|
122
|
+
- doc/classes/PageTemplate/DefineCommand.src/M000079.html
|
123
|
+
- doc/classes/PageTemplate/DefineCommand.src/M000080.html
|
124
|
+
- doc/classes/PageTemplate/FileSource.src/M000016.html
|
125
|
+
- doc/classes/PageTemplate/FileSource.src/M000017.html
|
126
|
+
- doc/classes/PageTemplate/FileSource.src/M000018.html
|
127
|
+
- doc/classes/PageTemplate/FileSource.src/M000019.html
|
128
|
+
- doc/classes/PageTemplate/FilterCommand.src/M000065.html
|
129
|
+
- doc/classes/PageTemplate/FilterCommand.src/M000066.html
|
130
|
+
- doc/classes/PageTemplate/FilterCommand.src/M000067.html
|
131
|
+
- doc/classes/PageTemplate/IfCommand.src/M000059.html
|
132
|
+
- doc/classes/PageTemplate/IfCommand.src/M000060.html
|
133
|
+
- doc/classes/PageTemplate/IfCommand.src/M000061.html
|
134
|
+
- doc/classes/PageTemplate/IfCommand.src/M000062.html
|
135
|
+
- doc/classes/PageTemplate/IfCommand.src/M000063.html
|
136
|
+
- doc/classes/PageTemplate/IfCommand.src/M000064.html
|
137
|
+
- doc/classes/PageTemplate/IncludeCommand.src/M000039.html
|
138
|
+
- doc/classes/PageTemplate/IncludeCommand.src/M000040.html
|
139
|
+
- doc/classes/PageTemplate/IncludeCommand.src/M000041.html
|
140
|
+
- doc/classes/PageTemplate/LoopCommand.src/M000011.html
|
141
|
+
- doc/classes/PageTemplate/LoopCommand.src/M000012.html
|
142
|
+
- doc/classes/PageTemplate/LoopCommand.src/M000013.html
|
143
|
+
- doc/classes/PageTemplate/LoopCommand.src/M000014.html
|
144
|
+
- doc/classes/PageTemplate/LoopCommand.src/M000015.html
|
145
|
+
- doc/classes/PageTemplate/Namespace.src/M000057.html
|
146
|
+
- doc/classes/PageTemplate/Namespace.src/M000058.html
|
147
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000002.html
|
148
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000004.html
|
149
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000006.html
|
150
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000008.html
|
151
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000009.html
|
152
|
+
- doc/classes/PageTemplate/NamespaceItem.src/M000010.html
|
153
|
+
- doc/classes/PageTemplate/Parser.src/M000031.html
|
154
|
+
- doc/classes/PageTemplate/Parser.src/M000032.html
|
155
|
+
- doc/classes/PageTemplate/Parser.src/M000033.html
|
156
|
+
- doc/classes/PageTemplate/Parser.src/M000034.html
|
157
|
+
- doc/classes/PageTemplate/Parser.src/M000035.html
|
158
|
+
- doc/classes/PageTemplate/Parser.src/M000036.html
|
159
|
+
- doc/classes/PageTemplate/Parser.src/M000037.html
|
160
|
+
- doc/classes/PageTemplate/Parser.src/M000038.html
|
161
|
+
- doc/classes/PageTemplate/Source.src/M000055.html
|
162
|
+
- doc/classes/PageTemplate/Source.src/M000056.html
|
163
|
+
- doc/classes/PageTemplate/StackableCommand.src/M000081.html
|
164
|
+
- doc/classes/PageTemplate/StackableCommand.src/M000082.html
|
165
|
+
- doc/classes/PageTemplate/StackableCommand.src/M000083.html
|
166
|
+
- doc/classes/PageTemplate/StackableCommand.src/M000084.html
|
167
|
+
- doc/classes/PageTemplate/StringSource.src/M000053.html
|
168
|
+
- doc/classes/PageTemplate/StringSource.src/M000054.html
|
169
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000047.html
|
170
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000048.html
|
171
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000049.html
|
172
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000050.html
|
173
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000051.html
|
174
|
+
- doc/classes/PageTemplate/SyntaxGlossary.src/M000052.html
|
175
|
+
- doc/classes/PageTemplate/Template.src/M000071.html
|
176
|
+
- doc/classes/PageTemplate/Template.src/M000072.html
|
177
|
+
- doc/classes/PageTemplate/Template.src/M000073.html
|
178
|
+
- doc/classes/PageTemplate/TextCommand.src/M000068.html
|
179
|
+
- doc/classes/PageTemplate/TextCommand.src/M000069.html
|
180
|
+
- doc/classes/PageTemplate/TextCommand.src/M000070.html
|
181
|
+
- doc/classes/PageTemplate/UnknownCommand.src/M000025.html
|
182
|
+
- doc/classes/PageTemplate/UnknownCommand.src/M000026.html
|
183
|
+
- doc/classes/PageTemplate/UnknownCommand.src/M000027.html
|
184
|
+
- doc/classes/PageTemplate/ValueCommand.src/M000042.html
|
185
|
+
- doc/classes/PageTemplate/ValueCommand.src/M000043.html
|
186
|
+
- doc/classes/PageTemplate/ValueCommand.src/M000044.html
|
187
|
+
- doc/classes/PageTemplate.src/M000001.html
|
188
|
+
- doc/files/lib
|
189
|
+
- doc/files/README_txt.html
|
190
|
+
- doc/files/lib/PageTemplate
|
191
|
+
- doc/files/lib/PageTemplate_rb.html
|
192
|
+
- doc/files/lib/PageTemplate/case_rb.html
|
193
|
+
- doc/files/lib/PageTemplate/commands_rb.html
|
194
|
+
- doc/files/lib/PageTemplate/htglossary_rb.html
|
195
|
+
- doc/files/lib/PageTemplate/parser_rb.html
|
42
196
|
- lib/PageTemplate
|
43
197
|
- lib/PageTemplate.rb
|
44
198
|
- lib/PageTemplate/case.rb
|
@@ -72,6 +226,9 @@ files:
|
|
72
226
|
- site/src/SiteMap
|
73
227
|
- site/src/version2
|
74
228
|
- tdata/dummy.txt
|
229
|
+
- tdata/include.txt
|
230
|
+
- tdata/include2.txt
|
231
|
+
- tdata/variable.txt
|
75
232
|
test_files:
|
76
233
|
- test.rb
|
77
234
|
rdoc_options: []
|