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

Version Path
spina-2.11.0 app/helpers/spina/admin/icons_helper.rb
spina-2.10.0 app/helpers/spina/admin/icons_helper.rb
spina-2.9.1 app/helpers/spina/admin/icons_helper.rb
spina-2.9.0 app/helpers/spina/admin/icons_helper.rb
spina-2.8.1 app/helpers/spina/admin/icons_helper.rb
spina-2.8.0 app/helpers/spina/admin/icons_helper.rb
spina-2.7.0 app/helpers/spina/admin/icons_helper.rb
spina-2.6.2 app/helpers/spina/admin/icons_helper.rb
spina-2.6.1 app/helpers/spina/admin/icons_helper.rb
spina-2.6.0 app/helpers/spina/admin/icons_helper.rb
spina-2.5.0 app/helpers/spina/admin/icons_helper.rb