From 425f46684203b8c3d7a5c51d1ddd76b594c95cd0 Mon Sep 17 00:00:00 2001 From: sterebooster Date: Sun, 24 Feb 2013 00:38:10 +0100 Subject: [PATCH 1/4] 'gist' liquid tag by @stereobooster. Fixes #463. --- lib/jekyll/tags/gist.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/jekyll/tags/gist.rb diff --git a/lib/jekyll/tags/gist.rb b/lib/jekyll/tags/gist.rb new file mode 100644 index 00000000..e7d79302 --- /dev/null +++ b/lib/jekyll/tags/gist.rb @@ -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 + end + + def render(context) + "" + end + end +end + +Liquid::Template.register_tag('gist', Jekyll::GistTag) From 7e7cee6e56595cd17e88e767bb6aaf590584997f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 24 Feb 2013 00:57:58 +0100 Subject: [PATCH 2/4] Strip space from the gist number, add test for gist tag --- lib/jekyll/tags/gist.rb | 4 ++-- test/test_tags.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/gist.rb b/lib/jekyll/tags/gist.rb index e7d79302..f881dd56 100644 --- a/lib/jekyll/tags/gist.rb +++ b/lib/jekyll/tags/gist.rb @@ -7,11 +7,11 @@ module Jekyll class GistTag < Liquid::Tag def initialize(tag_name, gist, tokens) super - @gist = gist + @gist = gist.strip end def render(context) - "" + "" end end end diff --git a/test/test_tags.rb b/test/test_tags.rb index 3d97410b..f58475b0 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -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 = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "write script tag" do + assert_match %r{}, @result + end + end end From cdd3c0ef0c8a69ef56bc297f5a99f849fe7eb297 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 24 Feb 2013 01:30:41 +0100 Subject: [PATCH 3/4] Remove 'type' attribute from script tag in gist liquid tag. --- lib/jekyll/tags/gist.rb | 2 +- test/test_tags.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/gist.rb b/lib/jekyll/tags/gist.rb index f881dd56..87a3f52f 100644 --- a/lib/jekyll/tags/gist.rb +++ b/lib/jekyll/tags/gist.rb @@ -11,7 +11,7 @@ module Jekyll end def render(context) - "" + "" end end end diff --git a/test/test_tags.rb b/test/test_tags.rb index f58475b0..783bb531 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -218,7 +218,7 @@ CONTENT end should "write script tag" do - assert_match %r{}, @result + assert_match %r{}, @result end end end From f8a90d711f6b69e00b89a46de89f155f9a98f8f3 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 24 Feb 2013 01:54:13 +0100 Subject: [PATCH 4/4] Using https protocol instead of http. --- lib/jekyll/tags/gist.rb | 2 +- test/test_tags.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/gist.rb b/lib/jekyll/tags/gist.rb index 87a3f52f..d3eb0b37 100644 --- a/lib/jekyll/tags/gist.rb +++ b/lib/jekyll/tags/gist.rb @@ -11,7 +11,7 @@ module Jekyll end def render(context) - "" + "" end end end diff --git a/test/test_tags.rb b/test/test_tags.rb index 783bb531..caefb9ac 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -218,7 +218,7 @@ CONTENT end should "write script tag" do - assert_match %r{}, @result + assert_match %r{}, @result end end end