Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
liquid tag to display a symbol from your svg icon file. Takes the symbol id as argument.
module Jekyll
class SvgiconTag < Liquid::Tag
def initialize(tag_name, icon, tokens)
super
@icon = icon.gsub(/\s+/, "")
end
def render(context)
"<svg class=\"icon\" role=\"img\" width=\"24\" height=\"24\"><use xlink:href=\"/assets/icons.svg\##{@icon}\"></use></svg>"
end
end
end
Liquid::Template.register_tag('svgicon', Jekyll::SvgiconTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.