7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/svg_icon/helper.rb', line 7
def svg_icon(name, options = {})
options = options.dup
icons = SvgIcon.icons_json
height = icons["height"] || 24
width = icons["width"] || 24
options[:viewBox] ||= "0 0 #{width} #{height}"
default_class = SvgIcon.configuration.default_class
options[:class] = "#{default_class} #{options[:class]}".strip if default_class.present?
body = icons.dig("icons", name.to_s, "body")
content = if body
body
else
"<!-- SVG icon file not found: '#{(name.to_s)}' -->"
end
"<svg xmlns='http://www.w3.org/2000/svg' #{icon_html_attributes(options)}>#{content}</svg>".html_safe
end
|