lib/stache/mustache/handler.rb in stache-1.1.0 vs lib/stache/mustache/handler.rb in stache-1.1.1
- old
+ new
@@ -33,11 +33,11 @@
mustache = ::#{mustache_class}.new
mustache.view = self
mustache.virtual_path = '#{virtual_path}'
mustache[:yield] = content_for(:layout)
- mustache.context.update(local_assigns)
+ mustache.context.push(local_assigns)
variables = controller.instance_variables
variables.delete(:@template)
variables -= controller.class.protected_instance_variables.to_a
variables.each do |name|
@@ -91,16 +91,17 @@
# render a bare Stache::View
if template.source.empty?
return Stache::Mustache::View
end
- const_name = ActiveSupport::Inflector.camelize(template.virtual_path.to_s)
+ const_name = ActiveSupport::Inflector.camelize(ActiveSupport::Inflector.underscore(template.virtual_path.to_s))
const_name = "#{Stache.wrapper_module_name}::#{const_name}" if Stache.wrapper_module_name
begin
const_name.constantize
rescue NameError, LoadError => e
# Only rescue NameError/LoadError concerning our mustache_class
- if e.message.match(/#{const_name}$/)
+ e_const_name = e.message.match(/ ([^ ]*)$/)[1]
+ if const_name.match(/#{e_const_name}(::|$)/)
Stache::Mustache::View
else
raise e
end
end