mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-01 10:15:03 -05:00
Merge pull request #822 from mojombo/gist-tag
Add 'gist' liquid tag to master
This commit is contained in:
19
lib/jekyll/tags/gist.rb
Normal file
19
lib/jekyll/tags/gist.rb
Normal 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)
|
||||
@@ -203,4 +203,22 @@ CONTENT
|
||||
assert_match %r{/2008/11/21/complex/}, @result
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user