Rails에서 bootstrap-ins를 간단히 사용
2616 단어 bootstrap-iconsRails
rails에서bootstrap-ins를 사용하는 방법
현재
v1.0.0-alpha5
는 최신이고 앞으로는 달라질 것이다.npm
npm install bootstrap-icons
yarnyarn add bootstrap-icons
다음은 app/helpers/application_helper.rb
에 다음과 같은 내용을 보충한다.module ApplicationHelper
...
# 追加
def icon(icon, options = {})
file = File.read("node_modules/bootstrap-icons/icons/#{icon}.svg")
doc = Nokogiri::HTML::DocumentFragment.parse file
svg = doc.at_css 'svg'
if options[:class].present?
svg['class'] += " " + options[:class]
end
doc.to_html.html_safe
end
end
뷰는 슬림이니까.=icon("hdd", class: "text-gray")
를 참고하십시오.Reference
이 문제에 관하여(Rails에서 bootstrap-ins를 간단히 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/mammosu/items/035daaa9e1de3c3cebf2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)