From 89afc86a5b4ff6bb1cbef5652e78907586af976f Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 3 Jul 2012 00:01:11 -0700 Subject: [PATCH] Friendlier error message when a non-default layout is not in the layouts directory. --- .../lib/middleman-core/core_extensions/rendering.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 3e129c10..4e08ad8b 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -115,9 +115,13 @@ module Middleman # handles cases like `style.css.sass.erb` content = nil while ::Tilt[path] - opts[:template_body] = content if content - content = render_individual_file(path, locs, opts, context) - path = File.basename(path, File.extname(path)) + begin + opts[:template_body] = content if content + content = render_individual_file(path, locs, opts, context) + path = File.basename(path, File.extname(path)) + rescue LocalJumpError => e + raise "Tried to render a layout (calls yield) at #{path} like it was a template. Non-default layouts need to be in #{source}/layouts." + end end # Certain output file types don't use layouts