Sinatra-Partial
Sinatra-Partial copied to clipboard
Pass block to partial to enable yielding from partials
Hi @archiloque
Thanks for this. It looks fine, but I either need a spec to go with it or an example I can use.
Regards, iain
Hello,
an example, since I'm not sure how to make a relevant test
- when using https://gist.github.com/seanami/496702 you can write sinatra helpers with blocks
- write this kind of partial
<form>
<% yield %>
</form>
- then declare a helper like this
def my_partial_with_block(&block)
buffer << partial(:'my_helper.html', &block)
end
- then in your erb file you can call the partial with a block
<% my_partial_with_block do %>
<!-- some html here -->
<% end %>
It's handy to make your templates cleaner when using things like bootstrap that require much boilerplate html.
Ok, thanks. I'll give it a look over the weekend and try to knock up some relevant specs for it.
regards, iain
After thinking about it I wonder if it would make sense to include the gist content in the gem since using partial with blocks like in rails is a not-so-rare usecase, what do you think ?