From 9d10b4274bd98b47f91e0dbf18c9f40ade78bcd3 Mon Sep 17 00:00:00 2001 From: Marcelo Canina Date: Mon, 19 Jun 2017 19:13:15 -0300 Subject: [PATCH 1/2] rename Liquid 4 has_key to key --- lib/jekyll-gist/gist_tag.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-gist/gist_tag.rb b/lib/jekyll-gist/gist_tag.rb index acb5f04..55a5d9b 100644 --- a/lib/jekyll-gist/gist_tag.rb +++ b/lib/jekyll-gist/gist_tag.rb @@ -14,10 +14,10 @@ def render(context) @settings = context.registers[:site].config['gist'] if tag_contents = determine_arguments(@markup.strip) gist_id, filename = tag_contents[0], tag_contents[1] - if context.has_key?(gist_id) + if context.key?(gist_id) gist_id = context[gist_id] end - if context.has_key?(filename) + if context.key?(filename) filename = context[filename] end noscript_tag = gist_noscript_tag(gist_id, filename) From 6b635e91b24ff04afcc14c82aca9264d89640ed5 Mon Sep 17 00:00:00 2001 From: Marcelo Canina Date: Wed, 21 Jun 2017 01:00:44 -0300 Subject: [PATCH 2/2] Update gist_tag.rb https://github.com/jekyll/jekyll-gist/pull/41#issuecomment-309809360 --- lib/jekyll-gist/gist_tag.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-gist/gist_tag.rb b/lib/jekyll-gist/gist_tag.rb index 55a5d9b..0895c15 100644 --- a/lib/jekyll-gist/gist_tag.rb +++ b/lib/jekyll-gist/gist_tag.rb @@ -14,10 +14,10 @@ def render(context) @settings = context.registers[:site].config['gist'] if tag_contents = determine_arguments(@markup.strip) gist_id, filename = tag_contents[0], tag_contents[1] - if context.key?(gist_id) + if context_contains_key?(context, gist_id) gist_id = context[gist_id] end - if context.key?(filename) + if context_contains_key?(context, filename) filename = context[filename] end noscript_tag = gist_noscript_tag(gist_id, filename) @@ -45,6 +45,16 @@ def determine_arguments(input) [matched[1].strip, matched[2].strip] if matched && matched.length >= 3 end + private + + def context_contains_key?(context, key) + if context.respond_to?(:has_key?) + context.has_key?(key) + else + context.key?(key) + end + end + def gist_script_tag(gist_id, filename = nil) url = "https://gist.github.com/#{gist_id}.js" url = "#{url}?file=#{filename}" unless filename.to_s.empty?