动态选择CSS标签

时间:2014-05-17 09:54:29

标签: ruby twitter-bootstrap

这是我的代码段

<div class="container">
      <div class="col-md-12">
        <% @posts.each do |post| %>
            <h1><a href="/posts/<%= post.id %>"><%= post.title %></a></h1>
            <p><%= post.body %></p>
            <div>
              <span class="badge"><%= calculate_time_difference(Time.now - post.updated_at)%></span>
              <span class="badge"><a href="/posts/<%= post.id %>/like">Like this post!</a></span>
              <span class="badge">Likes: <%= post.like_count %></span>
              <% post.tags.each do |tag| %>
              <% ["label-default", "label-primary", "label-success", "label-info", "label-danger", "label-warning"].each do |label| %>
              <!-- problematic part here -->
              <div class="pull-right"><span class="label <%= label %>"> <a href="/tags/<%= tag.name %>"><%= tag.name %></a></span></div>
          <%end%>
    <% end %>
    <hr>
    <% end %>
    </div>
  </div>

如何在post和tag循环中选择动态类标签?

0 个答案:

没有答案