Class Index [+]

Quicksearch

Ramaze::View::Mustache

Binding to Mustache templating engine.

Mustache uses user-defined class for rendering. Ramaze overwrites value, if controller defined same name variable as method that class defined.

@see github.com/defunkt/mustache

Public Class Methods

call(action, string) click to toggle source
    # File lib/ramaze/view/mustache.rb, line 20
20:       def self.call(action, string)
21:         context, path, ext = class_defined?(action)
22: 
23:         action.sync_variables(action)
24:         action.variables.each { |k, v| context[k.to_sym] = v }
25: 
26:         view = View.compile(string) { |s| ::Mustache::Template.new(s) }
27:         html = view.render(context)
28: 
29:         return html, 'text/html'
30:       end
class_defined?(action) click to toggle source
    # File lib/ramaze/view/mustache.rb, line 32
32:       def self.class_defined?(action)
33:         return RamazeContext.new(nil), nil, nil unless action.view
34: 
35:         path = File.dirname(action.view)
36: 
37:         klass = if FileTest.exist?(File.join(path, "#{action.name}.rb"))
38:           require File.join(path, action.name)
39:           ::Object.const_get(::Mustache.classify(action.name)) # or eval?
40:         else
41:           ::Mustache
42:         end
43: 
44:         return RamazeContext.new(klass.new), path, View.exts_of(self).first
45:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.