【问题标题】:Using link_to with i18n and glyphicon, Ruby on Rails将 link_to 与 i18n 和 glyphicon 一起使用,Ruby on Rails
【发布时间】:2015-01-28 12:16:02
【问题描述】:

我不知道如何正确使用带有国际化标签和字形图标的 link_to。

我的代码目前看起来像这样。

<%=link_to t('health_info.twitter_posts_featuredacc')+' <i class="fa fa-twitter"></i>'.html_safe, health_info_tweets_path(type: 'featured') %>

它会提取正确的翻译,但也会将 ''.html_safe 中的所有内容显示为普通的 html 代码,而不是字形图标。

提前致谢。

【问题讨论】:

    标签: ruby internationalization


    【解决方案1】:

    我会为此使用块语法:

    <%= link_to(health_info_tweets_path(type: 'featured')) do %>
      <%= t('health_info.twitter_posts_featuredacc') %>
      <i class="fa fa-twitter"></i>
    <% end %>
    

    【讨论】:

    • 我正要这样做,但我无法在答案的前 5 分钟内做到这一点。你回答得太快了。 :) Upvote 并接受已经完成。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 2014-01-22
    • 2015-01-08
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多