middleman: Support Padrino's partial to accept block

Padrino now supports passing a block to a partial.

Partial:

%h1 prefix
.haml-block
  = yield
%h3 postfix

Page:

= partial 'foo' do
  Yay, a codeblock!

Resulting HTML:

<h1>prefix</h1>
<div class="haml-block">
  Yay, a codeblock!
</div>
<h3>postfix</h3>

This functionality is absolutely awesome. Now Pardrino doesn’t fall behind Sass and Jade which have supported passing blocks to mixins since forever.

Unfortunately, this won’t work in Middleman. Middleman produces the following HTML:

    Yay, a codeblock!
<h1>prefix</h1>
<div class="haml-block">
  0
</div>
<h3>postfix</h3>

@ujifgc, a Padrino maintainer who was kind to implement this feature, supposes that the problem in Middleman might take place due to this monkey patch. He suggests that we should:

  1. determine why this monkey patch is there in the first place and
  2. either get rid of it or modify it to support modern Padrino.

The reason for the issue may hide elsewhere though.

Here’s a sandbox project that can be used to test the issue quickly: https://github.com/lolmaus/middleman-padrino-test-partial-block

PS Yes, i know that Padrino/Middleman partials can accept code blocks by processing them through capture_html, assigning the result to variables and passing the variables to partials. But this is just ugly. Partials should be able to accept code blocks naturally, just like mixins in Sass and Jade. Padrino already made that happen. Please make Middleman compatible.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

I know it has been a while, but this does in fact work:

<% partial "foo" do %>
  Bar
<% end %>

Then simply <%= yield %> in the partial.

I will look into adding that to the docs.