Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将HTML标记放入<;标签>;在RubyonRails中?_Html_Ruby On Rails - Fatal编程技术网

如何将HTML标记放入<;标签>;在RubyonRails中?

如何将HTML标记放入<;标签>;在RubyonRails中?,html,ruby-on-rails,Html,Ruby On Rails,如何将标签放入f.label标签中 <%= f.label :test %> 请求的输出: <label for="test">test<span>*</span></label> 测试* 这应该可以做到: <%= f.label :test, 'test<span>*</span>'.html_safe %> 您需要告诉rails,您给它的字符串不需要消毒。使用String#html_-s

如何将
标签放入
f.label
标签中

<%= f.label :test %>

请求的输出:

<label for="test">test<span>*</span></label>
测试*
这应该可以做到:

<%= f.label :test, 'test<span>*</span>'.html_safe %>

您需要告诉rails,您给它的字符串不需要消毒。使用
String#html_-safe

<%= f.label :test, "test<span>*</span>".html_safe %>

标签接受块,因此您可以执行以下操作:

<%= f.label :test do %>
   <span>*</span>
<%end%>

*

您将通过以下方式获得转义输出:
testspan*/span
这是最好的方式