代码之家  ›  专栏  ›  技术社区  ›  collimarco

Ruby:在ERB模板中捕获并重用HTML代码块

  •  1
  • collimarco  · 技术社区  · 4 年前

    请注意,我不能使用Rails或Javascript。

    有没有办法使用 只有Ruby/ERB ?

    在Rails中,我会这样做:

    <% content_for :mycontent do %>
      some html code
      that I want to capture
      etc
    <% end %>
    
    Then, here, in the same template, I can reuse the block...
    
    <%= content_for :mycontent %>
    
    Multiple times...
    
    <%= content_for :mycontent %>
    

    有没有不带导轨的等效设备?

    0 回复  |  直到 4 年前
    推荐文章