diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index ead3a645..08394c24 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -36,14 +36,14 @@ module Middleman @opts = opts @locs.each do |k, _| - if self.respond_to?(k) - msg = "Template local `#{k}` tried to overwrite an existing context value. Please renamed the key when passing to `locals`" + next unless self.respond_to?(k) - if app.build? - throw msg - else - logger.error(msg) - end + 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 + logger.error(msg) end end end