【问题标题】:Rails3 ActionView TagHelperRails3 ActionView TagHelper
【发布时间】:2013-04-12 22:40:51
【问题描述】:

我想得到像 html 这样的输出

<div>
  <div/>
  <a/>
</div>

为此,我编写了如下的 ruby​​ 代码

content_tag :div, '', class: 'handle' do
  content_tag :div, class: icon, style: 'display:inline;' do
    link_to name, edit_path(object), :remote => true
  end
end

这导致&lt;a&gt; 在第二个&lt;div&gt; 内。如何做到这一点?

【问题讨论】:

    标签: ruby-on-rails-3 actionview actionviewhelper


    【解决方案1】:

    您将链接代码放在内部 div 中,因此在内部进行渲染。

    在您的代码中,内部 div 之间的代码块将使链接在内部呈现。你需要把它带到外面

    content_tag :div, class: icon, style: 'display:inline;' do
      the link here should be outside
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-24
      • 2016-08-19
      • 2012-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-30
      相关资源
      最近更新 更多