Skip to content
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