class SemiStatic::TiltWrapper

Attributes

file[R]

Public Class Methods

new(wrapping_template, filename) click to toggle source
# File lib/semi_static/tilt_wrapper.rb, line 23
def initialize(wrapping_template, filename)
  @wrapping_template, @file = wrapping_template, filename
end
template(filename, body) click to toggle source
# 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

Private Class Methods

wrap(template) click to toggle source
# File lib/semi_static/tilt_wrapper.rb, line 10
def wrap(template)
  components = File.basename(template.file).split(".")
  if components.size > 2
    filename = template.file.chomp('.' + components.last)
    wrap new(template, filename)
  else
    template
  end
end

Public Instance Methods

render(scope=Object.new, locals={}, &block) click to toggle source
# 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