Class: SemiStatic::TiltWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/semi_static/tilt_wrapper.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrapping_template, filename) ⇒ TiltWrapper

Returns a new instance of TiltWrapper.



25
26
27
# File 'lib/semi_static/tilt_wrapper.rb', line 25

def initialize(wrapping_template, filename)
  @wrapping_template, @file = wrapping_template, filename
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



23
24
25
# File 'lib/semi_static/tilt_wrapper.rb', line 23

def file
  @file
end

Class Method Details

.template(filename, body) ⇒ Object



5
6
7
8
# File 'lib/semi_static/tilt_wrapper.rb', line 5

def template(filename, body)
  t = Tilt.new(filename, nil, :renderer => Redcarpet::Render::HTML.new(:hard_wrap => true)) {|t| body }
  wrap t
end

Instance Method Details

#render(scope = Object.new, locals = {}, &block) ⇒ Object



29
30
31
32
# File 'lib/semi_static/tilt_wrapper.rb', line 29

def render(scope=Object.new, locals={}, &block)
  template = Tilt.new(@file) {|t| @wrapping_template.render(scope, locals, &block) }
  template.render(scope, locals, &block)
end