3

私は現在Railsプロジェクトに参加しており、レイアウトの一部ではないビューでbodyタグで定義された属性をオーバーライドしたいと考えています。

このような:

app / views / layouts / application.haml

...header

%body
  = render 'shared/menu'

  .container
    = yield

別の見方で。bodyタグに特定の属性を持たせたい:

app / views / stuff / 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

これを達成する最も簡単な方法は何ですか?

4

1 に答える 1

-1

あなたはおそらくそれを提供することができます:

レイアウトで

%body{ yield(:body_attributes) }

ビューで

- provide(:body_attributes, { class: '', data: {} })
于 2013-03-12T22:43:30.253 に答える