Module: ActionView::Use::Helpers

Defined in:
lib/action_view/use/helpers.rb

Instance Method Summary collapse

Instance Method Details

#all_used_symbolsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/action_view/use/helpers.rb', line 16

def all_used_symbols
  html = +"" << '<svg xmlns="http://www.w3.org/2000/svg" display="none">'

  used_symbol_set.each do |name|
    html << '<symbol id="' << name << '">'
    html << SymbolRenderer.new(lookup_context).render(self, name).body
    html << "</symbol>"
  end

  html << "</svg>"
  html.html_safe
end

#use_symbol(name, escape: true, **opts) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/action_view/use/helpers.rb', line 6

def use_symbol(name, escape: true, **opts)
  used_symbol_set << name

  <<~HTML.html_safe
    <svg xmlns="http://www.w3.org/2000/svg" #{tag_builder.tag_options(opts, escape)}>
      <use href="##{name}" />
    </svg>
  HTML
end