Best way to use Twitter Bootstrap Icons as Links in Ruby on Rails 3?

后端 未结 5 1742
傲寒
傲寒 2020-12-30 16:04

What\'s the best way to use an icon provided by Twitter Bootstrap as a link in Rails 3?

Currently, I am using it like the pasted snippet, but the icon doesn\'t displ

5条回答
  •  自闭症患者
    2020-12-30 16:37

    I should create this helper:

    module BootstrapHelper
      def icon(*names)
        content_tag(:i, nil, :class => icon_classes(names))
      end
    
      private
      def icon_classes(*names)
        names.map{ |name| "icon-#{name}" }
      end
    end
    

    And use like this:

    link_to icon(:trash, :white), user_path(@user), method: :delete
    

提交回复
热议问题