Class: Stic::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/stic/renderer.rb

Defined Under Namespace

Modules: Environment

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blobObject (readonly)

Returns the value of attribute blob.



4
5
6
# File 'lib/stic/renderer.rb', line 4

def blob
  @blob
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/stic/renderer.rb', line 4

def name
  @name
end

#pathObject (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