Skip to content

Instantly share code, notes, and snippets.

@jessgusclark
Created October 24, 2018 20:28
Show Gist options
  • Save jessgusclark/b119b502ad854212d7f3eea0e2b63e8b to your computer and use it in GitHub Desktop.
Save jessgusclark/b119b502ad854212d7f3eea0e2b63e8b to your computer and use it in GitHub Desktop.
A simple liquid template for embedding GitHub gists on a Jekyll page
module Jekyll
class EmbedGist < Liquid::Tag
def initialize(tag_name, url, tokens)
super
# remove spaces from string:
@url = url.gsub!(/\s+/, '')
end
def render(context)
"<script src=\"#{@url}.js\"></script>"
end
end
end
Liquid::Template.register_tag('gist', Jekyll::EmbedGist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment