Commit 6a55ebe4 authored by Sylvester Keil's avatar Sylvester Keil

allow for overriding of bib template

parent 0178a0a4
...@@ -36,9 +36,13 @@ module Jekyll ...@@ -36,9 +36,13 @@ module Jekyll
opts.on('-s', '--style STYLE') do |style| opts.on('-s', '--style STYLE') do |style|
@style = style @style = style
end end
opts.on('-T', '--template TEMPLATE') do |template|
@bibliography_template = template
end end
argv = arguments.split(/(\B-[cfqpts]|\B--(?:cited|file|query|prefix|text|style|))/) argv = arguments.split(/(\B-[cfqptTs]|\B--(?:cited|file|query|prefix|text|style|template|))/)
parser.parse parser.parse
end end
...@@ -140,24 +144,28 @@ module Jekyll ...@@ -140,24 +144,28 @@ module Jekyll
end end
def bibliography_template def bibliography_template
return @bibliography_template if @bibliography_template @bibliography_template || config['bibliography_template']
def liquid_template
return @liquid_template if @liquid_template
tmp = config['bibliography_template'] || '{{reference}}' tmp = bibliography_template
case case
when tmp.nil? when tmp.nil?, tmp.empty?
tmp = '{{reference}}' tmp = '{{reference}}'
when site.layouts.key?(tmp) when site.layouts.key?(tmp)
tmp = site.layouts[tmp].content tmp = site.layouts[tmp].content
end end
@bibliography_template = Liquid::Template.parse(tmp) @liquid_template = Liquid::Template.parse(tmp)
end end
def bibliography_tag(entry, index) def bibliography_tag(entry, index)
return missing_reference unless entry return missing_reference unless entry
bibliography_template.render({ liquid_template.render({
'entry' => liquidify(entry), 'entry' => liquidify(entry),
'reference' => reference_tag(entry), 'reference' => reference_tag(entry),
'key' => entry.key, 'key' => entry.key,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment