From b1778a92cd3797772ed0b10772193897c5b0b8c7 Mon Sep 17 00:00:00 2001 From: Jim Cushing Date: Wed, 3 Feb 2016 16:55:11 -0500 Subject: [PATCH] fix partials used with blocks --- middleman-core/features/partials.feature | 7 +++++++ middleman-core/fixtures/partials-app/source/_block.erb | 3 +++ middleman-core/fixtures/partials-app/source/block.html.erb | 3 +++ middleman-core/lib/middleman-core/template_context.rb | 3 ++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 middleman-core/fixtures/partials-app/source/_block.erb create mode 100644 middleman-core/fixtures/partials-app/source/block.html.erb diff --git a/middleman-core/features/partials.feature b/middleman-core/features/partials.feature index 86509027..30773b46 100644 --- a/middleman-core/features/partials.feature +++ b/middleman-core/features/partials.feature @@ -50,3 +50,10 @@ Feature: Provide Sane Defaults for Partial Behavior Then I should see "File Not Found" When I go to "/_code_snippet.html" Then I should see "File Not Found" + +Scenario: Works with blocks + Given the Server is running at "partials-app" + When I go to "/block.html" + Then I should see "Start" + And I should see "Contents" + And I should see "End" diff --git a/middleman-core/fixtures/partials-app/source/_block.erb b/middleman-core/fixtures/partials-app/source/_block.erb new file mode 100644 index 00000000..179e0c82 --- /dev/null +++ b/middleman-core/fixtures/partials-app/source/_block.erb @@ -0,0 +1,3 @@ +Start +<%= yield %> +End diff --git a/middleman-core/fixtures/partials-app/source/block.html.erb b/middleman-core/fixtures/partials-app/source/block.html.erb new file mode 100644 index 00000000..613f7ccb --- /dev/null +++ b/middleman-core/fixtures/partials-app/source/block.html.erb @@ -0,0 +1,3 @@ +<% partial "block" do %> +Contents +<% end %> diff --git a/middleman-core/lib/middleman-core/template_context.rb b/middleman-core/lib/middleman-core/template_context.rb index 8d7fd784..cd0b50e8 100644 --- a/middleman-core/lib/middleman-core/template_context.rb +++ b/middleman-core/lib/middleman-core/template_context.rb @@ -96,8 +96,9 @@ module Middleman # # @param [String, Symbol] name The partial to render. # @param [Hash] options + # @param [Proc] block A block will be evaluated to return internal contents. # @return [String] - Contract Any, Or[Symbol, String], Hash => String + Contract Any, Or[Symbol, String], Hash => String, Maybe[Proc] => String def render(_, name, options={}, &block) name = name.to_s