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.
# 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
# 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.
Generated with the Darkfish Rdoc Generator 1.1.6.