在 Active Admin / Arbre 表格中,如何将 HTML (特别是换行符)放在标签中?
In Active Admin / Arbre form, how I can put HTML (specifically a line break) in a label?
这有点不正统,但我觉得应该不难。
我有一个有效的管理表单:
form do |f|
f.semantic_errors(*f.object.errors.keys)
f.inputs do
f.input :email
f.input :name
# read-only field that still matches formatting of form
li do
label "Last Update Time<br/>(except password changes)"
div f.object.last_update_time
end
end
f.actions
end
呈现时,last_update_time
标签不会将 <br/>
转换为换行符。同样,html 实体代码如 ©
(版权 (c)
)也不会被转换。
如何让 html 在该标签中呈现?
我试过的东西不起作用:
label "foo<br/>bar".html_safe
label raw("foo<br/>bar")
这样的块(在 label
上出现错误:“参数数量错误(给定 0,预期 1..3)”):
label do
"foo"
br
"bar"
end
有人知道这个技巧吗?
Alas Formtastic 不是基于 Arbre 构建的,并且在某种程度上被黑进了 ActiveAdmin。我会尝试用 Arbre 的 text_node
替换 Formtastic 的 label
下一步试试:
li do
text_node "<label>Last Update Time<br/>(except password changes)"</label>".html_safe
div f.object.last_update_time
end
©
必须在 text_node 里面太像了:
text_node "©".html_safe
这有点不正统,但我觉得应该不难。
我有一个有效的管理表单:
form do |f|
f.semantic_errors(*f.object.errors.keys)
f.inputs do
f.input :email
f.input :name
# read-only field that still matches formatting of form
li do
label "Last Update Time<br/>(except password changes)"
div f.object.last_update_time
end
end
f.actions
end
呈现时,last_update_time
标签不会将 <br/>
转换为换行符。同样,html 实体代码如 ©
(版权 (c)
)也不会被转换。
如何让 html 在该标签中呈现?
我试过的东西不起作用:
label "foo<br/>bar".html_safe
label raw("foo<br/>bar")
这样的块(在
label
上出现错误:“参数数量错误(给定 0,预期 1..3)”):label do "foo" br "bar" end
有人知道这个技巧吗?
Alas Formtastic 不是基于 Arbre 构建的,并且在某种程度上被黑进了 ActiveAdmin。我会尝试用 Arbre 的 text_node
替换 Formtastic 的label
下一步试试:
li do
text_node "<label>Last Update Time<br/>(except password changes)"</label>".html_safe
div f.object.last_update_time
end
©
必须在 text_node 里面太像了:
text_node "©".html_safe