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
Allow erb
and haml
helpers to take a block
#641
Allow erb
and haml
helpers to take a block
#641
Conversation
@alexeymuranov Could you provide a test? |
Here are the tests. I only made changes for Haml and ERB, but i imagine there are other template engines that can accept blocks. I was tempted to use meta-programming to define these two helpers in one loop, but i think it would make the documentation harder to generate. Maybe there was a reason meta-programming was not used here before. |
@alexeymuranov Some of them already support blocks, maybe you can go through and add support for the rest of them that will allow it? I think it's best to leave it without any meta-programming. This way it's obvious which template helpers are supported, and can easily be removed or deprecated. That is probably the intention. Maybe @rkh can comment further. |
@zzak, do you know which ones exactly support blocks? If you do, can you tell me please? |
@alexeymuranov you will have to check tilt, see tilt/lib/tilt/* and look for #evaluate in each template class. |
Could you also add this to liquid, slim, creole, wlang, yajl and rabl and corresponding tests? |
template(:a_page) { "<p>Contents.</p>\n" } | ||
get('/') do | ||
erb :main_outer_layout, :layout => false do | ||
erb :an_inner_layout, :layout => false do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inner erb call should not need the :layout => false
.
Do not know how to use layouts in creole, yajl, and rabl, will need to look for examples... |
@alexeymuranov creole, yajl and rabl all have tests, can you check there? these should all have tests, including the new block support. |
I do not see how to make a layout in creole for example. There are no such examples among tests, different layout engines are always used with creole. |
Maybe it doesn't work, those were just the ones were the code permits layouts. |
It is possible to call |
Also, still needs docs in README.md. |
I can add docs to README. However, i would need much more time to figure out how to use |
I guess the current code is fine. |
In Russian README, "Вложенные шаблоны" -> "Включённые шаблоны"
Move "Embedded Templates" subsection in English and Russian README to a more appropriate place.
In English and Russian README, rename "Embedded Templates" to "Literal Templates".
I have made several changes in English and Russian README, please tell me if you want them separated to another PR. In Russian README, i had to change the term "вложенные шаблоны" because in my opinion it was not an appropriate translation of "Inline Templates", and conflicted with "вложенные раскладки" for "nested layouts" that i was adding. I have also moved "Embedded Templates" subsection and renamed them to "Literal Templates". What do you think? Those are all in separate commits, but if you do not want to merge them now, i can make a separate pull request. |
Add README section "Templates with `yield` and nested layouts" in English and Russian.
Allow `erb` and `haml` helpers to take a block
What do you think about this? I have changed only
erb
andhaml
helpers because for other template engines i do not know which ones have "layouts".This is to be able to use nested layouts using
erb
andhaml
helpers. Real nested layouts, not in the sense of Rails.When i want to nest two layouts in my application, i currently can do like this:
I want to be able to do simply: