Sha256: 0197255fe90cc81c808e1f9fe9aaa709dfd8ccfa73d11bf4ea51045658b92db1
Contents?: true
Size: 563 Bytes
Versions: 10
Compression:
Stored size: 563 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")) doc = Nokogiri::XML(file) svg = doc.root svg[:class] = options[:class] ActiveSupport::SafeBuffer.new(svg.to_s) end private def read_file(path) File.exist?(path) || raise(FileNotFound, "File #{path} not found") File.read(path) end end end
Version data entries
10 entries across 10 versions & 1 rubygems