使用嵌套佈局我基本上與中間人2工作,但如果只能在中間人3做我可以切換到它在中間人
我layout.haml
有所有的樣板,同時作爲指數的佈局。
現在我想的inner.haml
佈局,將在頁面的其餘部分的工作,將繼承layout.haml
(在,我不會重複樣板部分條款),將incude一些額外常見的樣式/腳本,一些通用標記,然後將重新放置yield
塊。
目前我根本不知道從哪裏開始。我瞭解如何將inner.haml
設置爲默認佈局,並將layout.haml
設置爲「/」路線的佈局,但系統如何知道inner.haml
實際上嵌套在layout.haml
之內?
樣品設置
layout.haml
!!!5
%html
%head
%script(src="HTML5 shiv")
%title
My Site
\|
= yield_content :title
= stylesheet_link_tag "site.css"
= yield_content :page_styles
%body
%div(role="main")
= yield_content :content
%script(src="jquery")
= yield_content :page_scripts
index.html.haml
- content_for :title do
Index
- content_for :page_styles do
= stylesheet_link_tag "index.css"
- content_for :page_scripts do
%script(src="index.js")
- content_for :content do
Cool banner here
inner.haml
-# somehow inherits from/extends layout.haml
- content_for :page_styles do
-# somehow I'm putting some common content and then reinclude the block from the specific page
= stylesheet_link_tag "inner.css"
= yield_content :page_styles
-# same thing for page_scripts
- content_fir :content do
-# again I define some common HTML, then include page's content
我已經在使用content_for和yield_content了。當說分數時,你的意思是我應該把所有的common_inner_styles,common_inner_scripts和common_inner_markup分成不同的部分?我會很好,但有可能把內容放入部分?我的意思是我想要爲所有內部頁面定製內容的一些常用包裝元素 – Guard 2012-03-31 09:24:40