Class: Web::Narflates::Include

Inherits:
Object
  • Object
show all
Defined in:
lib/web/template.rb

Overview

:nodoc:

Instance Method Summary collapse

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



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