Module: Esvg::Helpers

Defined in:
lib/esvg/helpers.rb

Instance Method Summary collapse

Instance Method Details

#embed_svgs(*keys) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/esvg/helpers.rb', line 3

def embed_svgs(*keys)
  if Rails.env.production?
    Esvg.build_paths(keys).map { |path| javascript_include_tag(path, async: true) }.join("\n").html_safe
  else
    Esvg.embed(keys)
  end
end

#use_svg(name, options = {}, &block) ⇒ Object



11
12
13
14
15
# File 'lib/esvg/helpers.rb', line 11

def use_svg(name, options={}, &block)
  options[:content] = capture(&block).html_safe if block_given?

  Esvg.use(name, options)
end