Class: Stic::Renderer
- Inherits:
-
Object
- Object
- Stic::Renderer
- Defined in:
- lib/stic/renderer.rb
Defined Under Namespace
Modules: Environment
Instance Attribute Summary collapse
-
#blob ⇒ Object
readonly
Returns the value of attribute blob.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(blob) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(locals, &block) ⇒ Object
Constructor Details
#initialize(blob) ⇒ Renderer
Returns a new instance of Renderer.
6 7 8 9 |
# File 'lib/stic/renderer.rb', line 6 def initialize(blob) @blob = blob @path = blob.source_path end |
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob.
4 5 6 |
# File 'lib/stic/renderer.rb', line 4 def blob @blob end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/stic/renderer.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/stic/renderer.rb', line 4 def path @path end |
Instance Method Details
#render(locals, &block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/stic/renderer.rb', line 11 def render(locals, &block) engines = Tilt.templates_for(path.basename) engines.reduce(blob.content) do |content, engine| engine.new(path){ content.to_s }.render(Environment, locals, &block) end.html_safe end |