Ruby 函数中的 Font Awesome
Font Awesome inside Ruby function
我的 productions_helper.rb 中有一个 ruby 函数:
def new_applications(number, new_castings_for_user)
content_tag :span, "(#{number})", class: "icon-new-applications#{' highlight' if new_castings_for_user}"
end
我给它添加了一个很棒的字体图标:
def new_applications(number, new_castings_for_user)
content_tag :span, "(#{number})", fa_icon: "user-plus", class: "icon-new-applications#{' highlight' if new_castings_for_user}"
end
但是,该图标未显示在我的网站上。谁能告诉我我做错了什么?
好吧,您实际上并没有渲染图标。在您的代码中,您所做的只是将 fa_icon
的属性添加到 span 标记。除非有一些额外的代码可以解释这个属性,否则它不会起作用。试试这个
def new_applications(number, new_castings_for_user)
content_tag :span, class: "icon-new-applications#{' highlight' if new_castings_for_user}" do
[content_tag(:i, "", class: "fa fa-user-plus"), "(#{number})"].join.html_safe
end
end
我的 productions_helper.rb 中有一个 ruby 函数:
def new_applications(number, new_castings_for_user)
content_tag :span, "(#{number})", class: "icon-new-applications#{' highlight' if new_castings_for_user}"
end
我给它添加了一个很棒的字体图标:
def new_applications(number, new_castings_for_user)
content_tag :span, "(#{number})", fa_icon: "user-plus", class: "icon-new-applications#{' highlight' if new_castings_for_user}"
end
但是,该图标未显示在我的网站上。谁能告诉我我做错了什么?
好吧,您实际上并没有渲染图标。在您的代码中,您所做的只是将 fa_icon
的属性添加到 span 标记。除非有一些额外的代码可以解释这个属性,否则它不会起作用。试试这个
def new_applications(number, new_castings_for_user)
content_tag :span, class: "icon-new-applications#{' highlight' if new_castings_for_user}" do
[content_tag(:i, "", class: "fa fa-user-plus"), "(#{number})"].join.html_safe
end
end