Mustache is written and maintained by Chris Wanstrath. See: github.com/defunkt/mustache
When a scope argument is provided to MustacheTemplate#render, the instance variables are copied from the scope object to the Mustache view.
# File lib/sinatra/tilt.rb, line 678 678: def evaluate(scope=nil, locals={}, &block) 679: instance = @engine.new 680: 681: # copy instance variables from scope to the view 682: scope.instance_variables.each do |name| 683: instance.instance_variable_set(name, scope.instance_variable_get(name)) 684: end 685: 686: # locals get added to the view's context 687: locals.each do |local, value| 688: instance[local] = value 689: end 690: 691: # if we're passed a block it's a subview. Sticking it in yield 692: # lets us use {{yield}} in layout.html to render the actual page. 693: instance[:yield] = block.call if block 694: 695: instance.template = data unless instance.compiled? 696: 697: instance.to_html 698: end
# File lib/sinatra/tilt.rb, line 663 663: def initialize_engine 664: return if defined? ::Mustache 665: require_template_library 'mustache' 666: end
# File lib/sinatra/tilt.rb, line 668 668: def prepare 669: Mustache.view_namespace = options[:namespace] 670: Mustache.view_path = options[:view_path] || options[:mustaches] 671: @engine = options[:view] || Mustache.view_class(name) 672: options.each do |key, value| 673: next if ]view view_path namespace mustaches].include?(key.to_s) 674: @engine.send("#{key}=", value) if @engine.respond_to? "#{key}=" 675: end 676: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.