Merge pull request #822 from mojombo/gist-tag

Add 'gist' liquid tag to master
This commit is contained in:
Parker Moore 2013-02-23 16:59:53 -08:00
commit e0870fa178
2 changed files with 37 additions and 0 deletions

19
lib/jekyll/tags/gist.rb Normal file
View File

@ -0,0 +1,19 @@
# Gist Liquid Tag
#
# Example:
# {% gist 1234567 %}
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, gist, tokens)
super
@gist = gist.strip
end
def render(context)
"<script src=\"https://gist.github.com/#{@gist}.js\"> </script>"
end
end
end
Liquid::Template.register_tag('gist', Jekyll::GistTag)

View File

@ -203,4 +203,22 @@ CONTENT
assert_match %r{/2008/11/21/complex/}, @result assert_match %r{/2008/11/21/complex/}, @result
end end
end end
context "simple gist inclusion" do
setup do
@gist = 358471
content = <<CONTENT
---
title: My Cool Gist
---
{% gist #{@gist} %}
CONTENT
create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
end
should "write script tag" do
assert_match %r{<script src='https://gist.github.com/#{@gist}.js'>\s</script>}, @result
end
end
end end