Module: Lithium::Modules::Template
- Defined in:
- lib/lithium/modules/template.rb
Class Method Summary collapse
Instance Method Summary collapse
- #render(template, locals = {}, options = {}, &block) ⇒ Object
- #template_cache ⇒ Object
- #view(*args) ⇒ Object
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 = {}, = {}, &block template_cache.fetch(template) do ::Slim::Template.new(template, ) end.render(self, locals, &block) end |
#template_cache ⇒ Object
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 = args[1] layout = [:layout].nil? ? "layouts/layout.slim" : [:layout] render "#{layout}" do render *args end end |