Fix #1884 for realz

This commit is contained in:
Thomas Reynolds 2016-04-19 11:08:23 -07:00
commit b386dcdc40
2 changed files with 15 additions and 3 deletions

View file

@ -16,9 +16,9 @@ Feature: Don't allow template locals to overwrite template helpers
activate :test
page "/index.html", locals: { test: false }
page "/index.html", locals: { foo: false }
"""
And a file named "source/index.erb" with:
And a file named "source/index.html.erb" with:
"""
<%= foo %>
"""

View file

@ -133,8 +133,20 @@ module Middleman
# Add extension helpers to context.
@app.extensions.add_exposed_to_context(context)
locals.each do |k, _|
next unless context.respond_to?(k) && k != :current_path
msg = "Template local `#{k}` tried to overwrite an existing context value. Please renamed the key when passing to `locals`"
if @app.build?
throw msg
else
@app.logger.error(msg)
end
end
content = ::Middleman::Util.instrument 'builder.output.resource.render-template', path: File.basename(path) do
_render_with_all_renderers(path, locs, context, opts, &block)
_render_with_all_renderers(path, locals, context, options, &block)
end
# If we need a layout and have a layout, use it