Class: Flott::Template
- Inherits:
-
Proc
- Object
- Proc
- Flott::Template
- Defined in:
- lib/flott.rb
Overview
Class for compiled Template objects, that can later be evaluated in a Flott::Environment.
Instance Attribute Summary collapse
-
#environment ⇒ Object
The environment this template was evaluated in during the last evaluate call.
-
#page_cache ⇒ Object
Returns the Flott::Cache this Template originated from or nil, if no cache was used.
-
#pathes ⇒ Object
The pathes of the template and all included sub-templates.
-
#source ⇒ Object
The template’s source code after compilation.
Instance Method Summary collapse
-
#call(environment = Flott::Environment.new) ⇒ Object
(also: #evaluate)
Evaluates this Template Object in the Environment environment (first argument).
-
#initialize ⇒ Template
constructor
Sets up a Template instance.
-
#mtime ⇒ Object
Returns the newest mtime of all the involved #pathes.
Constructor Details
#initialize ⇒ Template
Sets up a Template instance.
481 482 483 484 |
# File 'lib/flott.rb', line 481 def initialize super @pathes = [] end |
Instance Attribute Details
#environment ⇒ Object
The environment this template was evaluated in during the last evaluate call. Returns nil if it wasn’t evaluated yet.
498 499 500 |
# File 'lib/flott.rb', line 498 def environment @environment end |
#page_cache ⇒ Object
Returns the Flott::Cache this Template originated from or nil, if no cache was used.
494 495 496 |
# File 'lib/flott.rb', line 494 def page_cache @page_cache end |
#pathes ⇒ Object
The pathes of the template and all included sub-templates.
487 488 489 |
# File 'lib/flott.rb', line 487 def pathes @pathes end |
#source ⇒ Object
The template’s source code after compilation.
490 491 492 |
# File 'lib/flott.rb', line 490 def source @source end |
Instance Method Details
#call(environment = Flott::Environment.new) ⇒ Object Also known as: evaluate
Evaluates this Template Object in the Environment environment (first argument).
507 508 509 510 511 512 513 514 515 516 |
# File 'lib/flott.rb', line 507 def call(environment = Flott::Environment.new, *) @environment = environment @environment.template = self @environment.page_cache = page_cache result = super attach_environment_to_output result rescue SyntaxError => e raise CallError.wrap(e) end |
#mtime ⇒ Object
Returns the newest mtime of all the involved #pathes.
501 502 503 |
# File 'lib/flott.rb', line 501 def mtime @pathes.map { |path| File.stat(path).mtime }.max end |