Merge pull request #822 from mojombo/gist-tag
Add 'gist' liquid tag to master
This commit is contained in:
commit
e0870fa178
|
@ -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)
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue