【问题标题】:Including bootstrap glyphicon in Rails link在 Rails 链接中包含引导 glyphicon
【发布时间】:2015-04-16 18:46:26
【问题描述】:

我正在尝试在 Rails 链接中包含引导字形图标。我想:

<%= link_to "<i class="glyphicon glyphicon-check"></i>&nbsp; Sign up".html_safe, signup_path, :class => "button" %>

但显然我包含字形图标的方式不正确,因为这在服务器上会产生错误:

unexpected tIDENTIFIER, expecting ')' ...=( link_to "<i class="glyphicon glyphicon-check"></i>" + ....

当我删除该部分时,链接有效。如何在链接/按钮中包含字形图标?

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4


    【解决方案1】:

    我愿意:

    <%= link_to signup_path, class: "button" do %>
      <i class="glyphicon glyphicon-check"></i>&nbsp; Sign up
    <% end %>
    

    我觉得它更清晰了。

    【讨论】:

      【解决方案2】:

      解决办法:

      <%= link_to "<i class='glyphicon glyphicon-check'></i>&nbsp; Sign up".html_safe, signup_path, :class => "button" %>
      

      所以要使用“glyphicon glyphicon-check”而不是“glyphicon glyphicon-check”。

      【讨论】:

        【解决方案3】:

        试试这个...例如link_to.my answer here

        <%= link_to (‘<i class=“fa fa-thumbs-up fa-lg”> </i>’).html_safe, vote_path(@image), :method=> :delete, :remote=> true%>
        

        【讨论】:

          猜你喜欢
          • 2011-05-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-10-10
          • 2014-07-17
          • 1970-01-01
          • 1970-01-01
          • 2011-06-15
          相关资源
          最近更新 更多