【问题标题】:haml to html translationhaml 到 html 的翻译
【发布时间】:2014-04-11 16:20:36
【问题描述】:

Rails-haml 专家可以翻译一下,这个haml代码是如何翻译成html的? 该页面源自此 url 。我只对第 1 行和第 12 行感兴趣。我使用了各种工具,在线转换器,但似乎不起作用:(

%table.table.table-bordered.table-striped#sortable{:data => {update_url:
sort_admin_things_path}}
  %thead
%tr
  %th= Title
  %th= Description
  %th  
  %tbody
    - @things.each do |thing|
  # make the <tr>'s draggable by adding the expected '.item' class
  # pass the item id into params[:id]
  %tr{data: {item_id: "#{thing.id}"}, class: 'item'}
    %td= thing.title
    %td= thing.description.truncate(20)
    %td
      = link_to 'show', admin_thing_path(thing), :class => 'btn'
      = link_to 'edit', edit_admin_thing_path(thing), :class => 'btn btn-primary'
      = link_to 'destroy', admin_thing_path(thing), method: :delete, confirm: "Are you sure?", :class => 'btn btn-danger'

【问题讨论】:

    标签: ruby-on-rails-4 haml


    【解决方案1】:

    缩进不正确。使用haml 最重要的是必须正确缩进才能工作。否则,由于缩进,您将遇到意外错误。

    无论如何..试试这个:

    <table class="table table-bordered table-striped" id="sortable" data-update_url = <%= sort_admin_things_path%> >
      <thead>
        <tr>
          <th>
            <%= Title %>
          </th>
          <th>
            <%= Description %>
          </th>
          <th>&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <% @things.each do |thing| %>
          <tr data-item_id= <%= thing.id %> class= "item" >
            <td>
              <%= thing.title %>
            </td>
            <td>
              <%= thing.description.truncate(20) %>
            </td>
            <td>
              <%= link_to 'show', admin_thing_path(thing), :class => 'btn' %>
              <%= link_to 'edit', edit_admin_thing_path(thing), :class => 'btn btn-primary' %>
              <%= link_to 'destroy', admin_thing_path(thing), method: :delete, confirm: "Are you sure?", :class => 'btn btn-danger' %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-11
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      相关资源
      最近更新 更多