How are Rails ERB’s layouts implemented? I tried looking through the source, but I couldn’t determine where/how they work.
I am specifically interested in how the yield part works, how erb includes the rendered view in a template.
The reason I need it, is so that I can use it for code generation, non Rails, non HTML related ( and because it would be interesting to know how they work )
Rails renders inside out, so it will render the show.html.erb first and store that in a variable. It will then render the layout
inside the layout you see
which will get replaced with the shot.html.erb text
This is also how the following work. In your page, you might say:
And then layer in your layout you can:
I like to think of it as just an inside-out setting of variables.