Created
October 24, 2018 20:28
-
-
Save jessgusclark/b119b502ad854212d7f3eea0e2b63e8b to your computer and use it in GitHub Desktop.
A simple liquid template for embedding GitHub gists on a Jekyll page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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