Module: Hobbit::Render
- Defined in:
- lib/hobbit/render.rb
Instance Method Summary collapse
- #default_layout ⇒ Object
- #find_template(template) ⇒ Object
- #layouts_path ⇒ Object
- #partial(template, locals = {}, options = {}, &block) ⇒ Object
- #render(template, locals = {}, options = {}, &block) ⇒ Object
- #template_engine ⇒ Object
- #views_path ⇒ Object
Instance Method Details
#default_layout ⇒ Object
5 6 7 |
# File 'lib/hobbit/render.rb', line 5 def default_layout "#{layouts_path}/application.#{template_engine}" end |
#find_template(template) ⇒ Object
9 10 11 |
# File 'lib/hobbit/render.rb', line 9 def find_template(template) "#{views_path}/#{template}.#{template_engine}" end |
#layouts_path ⇒ Object
13 14 15 |
# File 'lib/hobbit/render.rb', line 13 def layouts_path "#{views_path}/layouts" end |
#partial(template, locals = {}, options = {}, &block) ⇒ Object
17 18 19 20 |
# File 'lib/hobbit/render.rb', line 17 def partial(template, locals = {}, = {}, &block) template = find_template "_#{template}" _render template, locals, , &block end |
#render(template, locals = {}, options = {}, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hobbit/render.rb', line 22 def render(template, locals = {}, = {}, &block) template = find_template template layout = default_layout if .include? :layout layout = .delete :layout end if layout _render(layout, locals, ) { _render(template, locals, ) } else _render template, locals, end end |
#template_engine ⇒ Object
35 36 37 |
# File 'lib/hobbit/render.rb', line 35 def template_engine 'erb' end |
#views_path ⇒ Object
39 40 41 |
# File 'lib/hobbit/render.rb', line 39 def views_path 'views' end |