【问题标题】:How to write this code from haml into ERB?如何将此代码从haml写入ERB?
【发布时间】:2020-08-10 20:37:07
【问题描述】:

这段代码是用haml模板写的,怎么改写成erb

- @recipe.each_slice(3) do |recipes|
    .row
        - recipes.each do |recipe|
            .col-md-4
                .recipe
                    .image_wrapper
                        = link_to recipe do
                            = image_tag recipe.image.url(:medium)
                    %h2= link_to recipe.title, recipe

【问题讨论】:

标签: ruby-on-rails haml erb


【解决方案1】:

它可能看起来像这样:

<% @recipe.each_slice(3) do |recipes| %>
  <div class="row">
    <% recipes.each do |recipe| %>
      <div class="col-md-4">
        <div class="recipe">
          <div class="image_wrapper">
            <%= link_to recipe do %>
              <%= image_tag recipe.image.url(:medium) %>
            <% end %>
            <h2><%= link_to recipe.title, recipe %></h2>
          </div>
        </div>
      </div>
    <% end %>
  </div>
<% end %>

【讨论】:

    猜你喜欢
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 2013-04-12
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    相关资源
    最近更新 更多