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.



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

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



21
22
23
# File 'lib/semi_static/tilt_wrapper.rb', line 21

def file
  @file
end

Class Method Details

.template(filename, body) ⇒ Object



3
4
5
6
# File 'lib/semi_static/tilt_wrapper.rb', line 3

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



27
28
29
30
# File 'lib/semi_static/tilt_wrapper.rb', line 27

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