class BridgetownInlineSvg::Tag
Attributes
attributes[R]
context[R]
markup[R]
svg_path[R]
Public Instance Methods
build()
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 8 def build liquid_tag "svg", :render end
render(markup, builder)
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 12 def render(markup, builder) @context = builder.context @markup = markup interpolate_variables_in_markup! set_svg_path_and_attributes! return unless svg_path add_file_to_dependency! render_svg end
Private Instance Methods
add_file_to_dependency!()
click to toggle source
When we change the svg, it'll regenerate our page.
# File lib/bridgetown-inline-svg/tag.rb, line 39 def add_file_to_dependency! if context.registers[:page]&.key?("path") site.regenerator.add_dependency( site.in_source_dir(context.registers[:page]["path"]), svg_path ) end end
interpolate_variables_in_markup!()
click to toggle source
Parse any variables in our Markup
# File lib/bridgetown-inline-svg/tag.rb, line 29 def interpolate_variables_in_markup! @markup = Liquid::Template.parse(markup).render(context) end
options()
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 56 def options config["svg"] || {} end
render_svg()
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 48 def render_svg render_svg_class.new(svg_path, attributes).call end
render_svg_class()
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 52 def render_svg_class options["optimize"] == true ? RenderOptimizedSvg : RenderSvg end
set_svg_path_and_attributes!()
click to toggle source
# File lib/bridgetown-inline-svg/tag.rb, line 33 def set_svg_path_and_attributes! @svg_path, @attributes = Markup.parse(markup) @svg_path = Bridgetown.sanitized_path(site.source, svg_path) end