Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass block to partial to enable yielding from partials #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Pass block to partial to enable yielding from partials #12

wants to merge 1 commit into from

Conversation

archiloque
Copy link

No description provided.

@yb66
Copy link
Owner

yb66 commented Nov 7, 2015

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

@archiloque
Copy link
Author

Hello,

an example, since I'm not sure how to make a relevant test

<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.

@yb66
Copy link
Owner

yb66 commented Nov 7, 2015

Ok, thanks. I'll give it a look over the weekend and try to knock up some relevant specs for it.

regards,
iain

@archiloque
Copy link
Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants