2013-03-12 25 views
2

我當前在Rails項目中,我想重寫在不屬於佈局的視圖中的body標記中定義的屬性。覆蓋HAML中的主體屬性

像這樣:

應用/視圖/佈局/ application.haml

...header 

%body 
    = render 'shared/menu' 

    .container 
    = yield 

在另一視圖。我想身體標記有一定的屬性:

應用程序/視圖/材料/ index.haml

{data: {spy: 'scroll', target: '.d-sidebar', :'twttr-rendered' => 'true'}} << these attributes should apper in the body tag of the layout file. They should only be visible on the sub page 

什麼是實現這一目標的最簡單的方法?

回答

-1

你也許可以提供它:

佈局

%body{ yield(:body_attributes) } 

鑑於

- provide(:body_attributes, { class: '', data: {} }) 
+1

不幸的是這(身體..產量命令)引發錯誤 '未定義的方法'地圖'爲「」:ActiveSupport :: SafeBuffer' – leifg 2013-03-14 20:57:33