Module: ActionTree::Plugins::Tilt::Helpers

Defined in:
lib/action_tree/plugins/tilt.rb

Instance Method Summary collapse

Instance Method Details

#render(path, layout_namespace = nil, &blk) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/action_tree/plugins/tilt.rb', line 42

def render(path, layout_namespace=nil, &blk)
  path = ::File.join(@__match.view_path, path)
  
  template = ::ActionTree::Plugins::Tilt::CACHE.fetch(
    path) { Tilt.new(path, nil, {}) }
  
  if respond_to?(:content_type)
    content_type(template.class.default_mime_type)
  end

  result = template.render(self, &blk)

  layout = @__match.layout(layout_namespace)
  if layout && !%w{sass scss less coffee}.include?(File.extname(path))
    render(layout, :AbSoLuTeLy_No_LaYoUt) { result }
  else
    result
  end
end