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

Version Path
spina-2.4.0 app/helpers/spina/admin/icons_helper.rb
spina-2.3.5 app/helpers/spina/admin/icons_helper.rb
spina-2.3.4 app/helpers/spina/admin/icons_helper.rb
spina-2.3.3 app/helpers/spina/admin/icons_helper.rb
spina-2.3.2 app/helpers/spina/admin/icons_helper.rb
spina-2.3.1 app/helpers/spina/admin/icons_helper.rb
spina-2.3.0 app/helpers/spina/admin/icons_helper.rb
spina-2.2.0 app/helpers/spina/admin/icons_helper.rb
spina-2.1.1 app/helpers/spina/admin/icons_helper.rb
spina-2.1.0 app/helpers/spina/admin/icons_helper.rb