3

我目前在 Rails 项目中,我想在不属于布局的视图中覆盖 body 标记中定义的属性。

像这样:

应用程序/视图/布局/application.haml

...header

%body
  = render 'shared/menu'

  .container
    = yield

换个角度看。我希望 body 标签具有某些属性:

应用程序/视图/东西/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 回答