Module: Avo::Icons::Helpers

Defined in:
lib/avo/icons/helpers.rb

Instance Method Summary collapse

Instance Method Details

#svg(file_name, **args) ⇒ String

Use inline_svg gem but with our own finder implementation.

Examples:

svg("heroicons/outline/user", class: "w-6 h-6")
svg("my-icon", class: "w-4 h-4", aria: { hidden: true })

Parameters:

  • file_name (String)

    The name of the SVG file (with or without .svg extension)

  • args (Hash)

    Additional arguments to pass to inline_svg

Returns:

  • (String)

    The inline SVG HTML



11
12
13
14
15
16
17
18
19
# File 'lib/avo/icons/helpers.rb', line 11

def svg(file_name, **args)
  return if file_name.blank?

  file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"

  with_asset_finder(Avo::Icons::SvgFinder) do
    inline_svg file_name, **args
  end
end