Skip to content

rename Liquid 4 has_key to key to add compatibility for liquid 4 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/jekyll-gist/gist_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_contains_key?(context, gist_id)
gist_id = context[gist_id]
end
if context.has_key?(filename)
if context_contains_key?(context, filename)
filename = context[filename]
end
noscript_tag = gist_noscript_tag(gist_id, filename)
Expand Down Expand Up @@ -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?
Expand Down