/usr/lib/ruby/1.8/ramaze/view/mustache.rb is in libramaze-ruby1.8 2010.06.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | require 'mustache'
module Ramaze
module View
# 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 http://github.com/defunkt/mustache
module Mustache
def self.call(action, string)
context, path, ext = class_defined?(action)
action.sync_variables(action)
action.variables.each { |k, v| context[k.to_sym] = v }
view = View.compile(string) { |s| ::Mustache::Template.new(s) }
html = view.render(context)
return html, 'text/html'
end
def self.class_defined?(action)
return ::Mustache::Context.new(nil), nil, nil unless action.view
path = File.dirname(action.view)
klass = if FileTest.exist?(File.join(path, "#{action.name}.rb"))
require File.join(path, action.name)
::Object.const_get(::Mustache.classify(action.name)) # or eval?
else
::Mustache
end
return ::Mustache::Context.new(klass.new), path, View.exts_of(self).first
end
end
end
end
|