2018-08-31

시나트라3

: Layouts 

< web organizing techi > 
  • [q] Another very powerful way for organizing our website code is by using layouts. 
    • it's not uncommon when we're bui..
** start of layout 
<%= yield %>
** end of layout


  • [q] So, yield is essentially saying the template code drops in right ..yield that happens automatically before rendering that template. 
  • code example : ~~.erb
    <html> 
        <head> 
        </head>
        <body>
            <div id="navigation">
                <%= erb :navigation %>
            </div>
            <div id="main-content">        
                <%= yield %>
            </div>
        </body>
    </html> 

  •     
    • You can see I have those ERB tags with yield inside, that's where the template part would be dropped in.
    • So, it would be just a small bit of code that gets dropped in to this larger layout. 
    • So, my template file no longer has to have all the beginning and ending HTML, that's going to be in my layout. 
  • Point : Layouts : Render template inside common page elements. 

댓글 없음:

댓글 쓰기