Выдать атрибут HTML через slim
Я пытаюсь сгенерировать атрибут html tag в slim через content_for.
Вывод, который я хотел бы получить, выглядит примерно так:
body data-turbolinks="false"
То, что я пробовал (эта работа) следующее:
с моей точки зрения
- content_for(:body_attributes) do
=false
и из моего шаблона приложения
body data-turbolinks=(yield(:body_attributes) if content_for?(:body_attributes))
Но я не могу найти правильный синтаксис, если я хочу передать атрибут И его значение из моего content_for.
Я перепробовал много вещей без шансов, таких как:
body*{(yield(:body_attributes) if content_for?(:body_attributes)}
или же
body[(yield(:body_attributes) if content_for?(:body_attributes)]
с чем-то вроде этого на мой взгляд:
- content_for(:body_attributes) do
= "#{'data-attribute=false'}"
Спасибо за любую идею!
По поводу комментариев:
# Template
body*{yield(:body_attributes) if content_for?(:body_attributes)}
# View
- content_for(:body_attributes) do
="data-turbolinks=>false"
ИЛИ ЖЕ
# Template
body*{yield(:body_attributes) if content_for?(:body_attributes)}
# View
- content_for(:body_attributes) do
data-turbolinks=false
Производит:
syntax error, unexpected modifier_if, expecting => s(({yield(:body_attributes) if content_for?(:body_attributes
# Template
body(yield(:body_attributes) if content_for?(:body_attributes))
# View
- content_for(:body_attributes) do
="data-turbolinks=>false"
ИЛИ ЖЕ
# Template
body(yield(:body_attributes) if content_for?(:body_attributes))
# View
- content_for(:body_attributes) do
data-turbolinks=false
Производит:
Slim::Parser::SyntaxError Expected attribute