Module: Pulse::SvgHelper

Included in:
Component
Defined in:
app/lib/pulse/svg_helper.rb

Overview

Helpers for inline svg

Instance Method Summary collapse

Instance Method Details

#render_svg(name, **options) ⇒ Object

Note:

Do not include the .svg suffix in the filename

Render an embedded svg document

Parameters:

  • name (String)

    any filename present in the asset pipeline search paths

  • options (Hash)

    any additional options which inline_svg_tag accepts

See Also:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/lib/pulse/svg_helper.rb', line 11

def render_svg(name, **options)
  if options[:title].blank?
    options[:aria_hidden] ||= true
    options[:aria] = nil
  else
    options[:aria] ||= true
  end
  options[:nocomment] ||= true
  options[:class] = class_names(
    options[:class],
    options[:classes]
  )

  filename = "#{name}.svg"
  inline_svg_tag(filename, **options)
end