Class: Web::Narflates::Include
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(filename, vars, template_list) ⇒ Include
constructor
A new instance of Include.
- #print(globals, io) ⇒ Object
Constructor Details
#initialize(filename, vars, template_list) ⇒ Include
Returns a new instance of Include.
337 338 339 340 341 |
# File 'lib/web/template.rb', line 337 def initialize (filename, vars, template_list) @vars = vars @filename = filename @template_list = template_list end |
Instance Method Details
#print(globals, io) ⇒ Object
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/web/template.rb', line 343 def print (globals,io) # resolve filename if it is var filename = if @filename =~ /^\$(.*)/ globals.resolve( $1 ).value else @filename end # load file unless File.exists? Web::Narflates.template_file(filename) raise(TemplateException.new("Could not locate template file: " + filename)) end templater = Narflates.new(filename,@query) if @vars == nil templater.parse(io, globals ) else templater.parse(io, Scope.new(globals.resolve(@vars).value)) end @template_list.concat( templater.templates ) end |