Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow partials accept blocks #1504
It is awesome how Jade allows you to call mixins with different options and content blocks.
mixin article(title) .article .article-wrapper h1= title if block block else p No content provided +article('Hello world') +article('Good news, everyone!') p This is my p Amazing article
The same functionality is found in Sass, but surprisingly is missing in Padrino's template engines. Padrino has partials functionality abstracted out of template engines into a Padrino helper, and Padrino partial helper does not accept content blocks! :(
Middleman introduces the wrap_layout helper that lets you pass a block to a layout (which in this case is almost the same as partial). Unfortunately, it does not accept options, so you can't, for example, pass local variables. :( Also, migrating partials into templates would be an ugly workaround.
I've managed to mimic the desired funcitonality by leveraging Padrino's
I tried manually creating a helper with your code in a sandbox Middleman project and it didn't work out. :(
It's not producing an error as i had said (have you added commits?), but it doesn't work as expected.
I've got a partial:
%h1 prefix .haml-block = yield %h3 postfix
I call it like this:
= partial 'foo' do Am i the only one around here who has this failing?
Am i the only one around here who has this failing? <h1>prefix</h1> <div class="haml-block"> 0 </div> <h3>postfix</h3>
I fixed the issue and added a test.
I'm aware that middleman stays broken but it's because recent improvements to padrino rendering extensions. The problem is, as I understand, the monkey patch https://github.com/middleman/middleman/blob/master/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb#L74 that expects old code.
Investigate the reasons of monkey patching, remove them. Or patch to use