Skip to content

Commit 18efb2a

Browse files
marcanuyjekyllbot
authored andcommitted
rename Liquid 4 has_key to key to add compatibility for liquid 4 (#41)
Merge pull request 41
1 parent 8f2a3e2 commit 18efb2a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/jekyll-gist/gist_tag.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def render(context)
1414
@settings = context.registers[:site].config['gist']
1515
if tag_contents = determine_arguments(@markup.strip)
1616
gist_id, filename = tag_contents[0], tag_contents[1]
17-
if context.has_key?(gist_id)
17+
if context_contains_key?(context, gist_id)
1818
gist_id = context[gist_id]
1919
end
20-
if context.has_key?(filename)
20+
if context_contains_key?(context, filename)
2121
filename = context[filename]
2222
end
2323
noscript_tag = gist_noscript_tag(gist_id, filename)
@@ -45,6 +45,16 @@ def determine_arguments(input)
4545
[matched[1].strip, matched[2].strip] if matched && matched.length >= 3
4646
end
4747

48+
private
49+
50+
def context_contains_key?(context, key)
51+
if context.respond_to?(:has_key?)
52+
context.has_key?(key)
53+
else
54+
context.key?(key)
55+
end
56+
end
57+
4858
def gist_script_tag(gist_id, filename = nil)
4959
url = "https://gist.github.com/#{gist_id}.js"
5060
url = "#{url}?file=#{filename}" unless filename.to_s.empty?

0 commit comments

Comments
 (0)