Module: Hobbit::Mote
- Includes:
- Mote::Helpers
- Defined in:
- lib/hobbit/mote.rb
Instance Method Summary collapse
- #default_layout ⇒ Object
- #find_template(template) ⇒ Object
- #layouts_path ⇒ Object
- #partial(template, params = {}, context = self) ⇒ Object
- #render(template, params = {}, context = self) ⇒ Object
- #views_path ⇒ Object
Instance Method Details
#default_layout ⇒ Object
7 8 9 |
# File 'lib/hobbit/mote.rb', line 7 def default_layout "#{layouts_path}/application.mote" end |
#find_template(template) ⇒ Object
11 12 13 |
# File 'lib/hobbit/mote.rb', line 11 def find_template(template) "#{views_path}/#{template}.mote" end |
#layouts_path ⇒ Object
15 16 17 |
# File 'lib/hobbit/mote.rb', line 15 def layouts_path "#{views_path}/layouts" end |
#partial(template, params = {}, context = self) ⇒ Object
19 20 21 22 |
# File 'lib/hobbit/mote.rb', line 19 def partial(template, params = {}, context = self) template = find_template "_#{template}" mote template, params, context end |
#render(template, params = {}, context = self) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hobbit/mote.rb', line 24 def render(template, params = {}, context = self) template = find_template template layout = default_layout if params.include? :layout layout = params.delete :layout end if layout params = params.merge content: mote(template, params, context) mote layout, params, context else mote template, params, context end end |
#views_path ⇒ Object
38 39 40 |
# File 'lib/hobbit/mote.rb', line 38 def views_path 'views' end |