Sha256: e95f4e47607bd2f9a26f0a133dcddd49a03df2ebb0dded2f2865f2cb66a5e1a8
Contents?: true
Size: 554 Bytes
Versions: 11
Compression:
Stored size: 554 Bytes
Contents
require 'nokogiri' module Spina::Admin module IconsHelper class FileNotFound < StandardError end def heroicon(name, style: :outline, **options) file = read_file(Spina::Engine.root.join("app/assets/icons/heroicons", style.to_s, "#{name}.svg")) return "" if file.nil? doc = Nokogiri::XML(file) svg = doc.root svg[:class] = options[:class] ActiveSupport::SafeBuffer.new(svg.to_s) end private def read_file(path) return nil unless File.exist?(path) File.read(path) end end end
Version data entries
11 entries across 11 versions & 1 rubygems