新手问题 div 如何写成 content_tag

autumnwolf · April 24, 2014 · Last by autumnwolf replied at April 24, 2014 · 2099 hits
上面的 div 如何写成 content-tag? 如果像下面的话,如果加入 style 和 id 呢? ```erb <%= content_tag :div, class: "strong" do -%> Hello world! <% end -%> # => Hello world!
http://apidock.com/rails/ActionView/Helpers/TagHelper/content_tag
<%= content_tag :div, class: "strong", id: "tab-1", style: "display: block" do -%>
  Hello world!
<% end -%>

=>

<div class="strong" id="tab-1" style="display: block">Hello world!</div>

如果没有别的标签

<%= content_tag :div, "Hello world!", class: "strong", id: "tab-1", style: "display: block" -%>

#1 楼 @miclle 谢谢 也尝试这个 不过落下个 do

You need to Sign in before reply, if you don't have an account, please Sign up first.