Module: Lithium::Modules::Template

Defined in:
lib/lithium/modules/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_layout(layout = nil) ⇒ Object



6
7
8
# File 'lib/lithium/modules/template.rb', line 6

def self.default_layout layout = nil
    "layouts/layout.slim" if layout.nil?
end

Instance Method Details

#render(template, locals = {}, options = {}, &block) ⇒ Object



10
11
12
13
14
# File 'lib/lithium/modules/template.rb', line 10

def render template, locals = {}, options = {}, &block
  template_cache.fetch(template) do
    ::Slim::Template.new(template, options)
  end.render(self, locals, &block)
end

#template_cacheObject



25
26
27
# File 'lib/lithium/modules/template.rb', line 25

def template_cache
  Thread.current[:templates_cache] ||= Tilt::Cache.new
end

#view(*args) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/lithium/modules/template.rb', line 16

def view *args
  options = args[1]
  layout = options[:layout].nil? ? "layouts/layout.slim" : options[:layout]

  render "#{layout}" do
    render *args
  end
end