Class: RailsHeroicons::Icons
- Inherits:
-
Object
- Object
- RailsHeroicons::Icons
- Defined in:
- lib/rails_heroicons/icons.rb
Instance Method Summary collapse
Instance Method Details
#icon(name, style, class_name) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rails_heroicons/icons.rb', line 8 def icon(name, style, class_name) file_path = RailsHeroicons.root("lib/rails_heroicons/icons/#{style}/#{name}.svg") begin file_data = File.read(file_path) rescue raise RailsHeroicons::IconNotFound end if class_name.present? frag = Nokogiri::HTML.fragment(file_data) frag.child.set_attribute('class', class_name) frag.child.set_attribute('alt', name) file_data = frag.to_s end file_data.html_safe end |