Class: Jekyll::Scholar::ReferenceTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Scholar::ReferenceTag
- Includes:
- Utilities
- Defined in:
- lib/jekyll/scholar/tags/reference.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Attributes included from Utilities
#bibtex_file, #config, #context, #query, #site
Instance Method Summary collapse
-
#initialize(tag_name, arguments, tokens) ⇒ ReferenceTag
constructor
A new instance of ReferenceTag.
- #render(context) ⇒ Object
Methods included from Utilities
#base_url, #bibliography, #bibtex_options, #bibtex_path, #cite, #cite_details, #cited_references, #content_tag, #details_file_for, #details_link_for, #details_path, #entries, #extend_path, #generate_details?, #link_to, #set_context_to
Constructor Details
#initialize(tag_name, arguments, tokens) ⇒ ReferenceTag
Returns a new instance of ReferenceTag.
9 10 11 12 13 14 |
# File 'lib/jekyll/scholar/tags/reference.rb', line 9 def initialize(tag_name, arguments, tokens) super @config = Scholar.defaults.dup @key, @file = arguments.strip.split(/\s*,\s*/, 2) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/jekyll/scholar/tags/reference.rb', line 7 def file @file end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/jekyll/scholar/tags/reference.rb', line 7 def key @key end |
Instance Method Details
#render(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jekyll/scholar/tags/reference.rb', line 16 def render(context) set_context_to context bib = unless file.nil? BibTeX.open(file, { :filter => :latex }) else set_context_to context bibliography end entry = bib[key] if bib.key?(key) CiteProc.process entry.to_citeproc, :style => config['style'], :locale => config['locale'], :format => 'html' else "(missing reference)" end rescue "(#{key})" end |