Module: Mote::Render
- Includes:
- Helpers
- Defined in:
- lib/mote/render.rb
Class Method Summary collapse
Instance Method Summary collapse
- #mote_path(template) ⇒ Object
- #partial(template, locals = {}) ⇒ Object
- #render(template, locals = {}, layout = ) ⇒ Object
- #view(template, locals = {}, layout = ) ⇒ Object
Class Method Details
.setup(app) ⇒ Object
4 5 6 7 8 |
# File 'lib/mote/render.rb', line 4 def self.setup(app) app.settings[:mote] ||= {} app.settings[:mote][:views] ||= File.("views", Dir.pwd) app.settings[:mote][:layout] ||= "layout" end |
Instance Method Details
#mote_path(template) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mote/render.rb', line 22 def mote_path(template) if template.end_with?(".mote") return template else return File.join(settings[:mote][:views], "#{template}.mote") end end |
#partial(template, locals = {}) ⇒ Object
18 19 20 |
# File 'lib/mote/render.rb', line 18 def partial(template, locals = {}) return mote(mote_path(template), locals.merge(app: self), TOPLEVEL_BINDING) end |
#render(template, locals = {}, layout = ) ⇒ Object
10 11 12 |
# File 'lib/mote/render.rb', line 10 def render(template, locals = {}, layout = settings[:mote][:layout]) res.write(view(template, locals, layout)) end |
#view(template, locals = {}, layout = ) ⇒ Object
14 15 16 |
# File 'lib/mote/render.rb', line 14 def view(template, locals = {}, layout = settings[:mote][:layout]) return partial(layout, locals.merge(content: partial(template, locals))) end |