class Jekyll::Geolexica::JbuilderTag::JbuilderWrapper
Instance of this class becomes self
in Jbuilder templates. It provides access to Jbuilder instance and current Jekyll
context via json
and context
accessors, respectively. There are convenient accessors to site
and page
Jekyll
context variables, too.
@example
# Should render {"time": "<time when site was generated>"} json.now context["site"]["time"] # Alternatively json.now site["time"]
Public Class Methods
new(context)
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 33 def initialize(context) @builder = Jbuilder.new @context = context end
Public Instance Methods
context()
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 42 def context @context end
eval_source(source)
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 54 def eval_source(source) instance_eval(source) rescue raise Error.new(source) end
json()
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 38 def json @builder end
page()
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 46 def page @context["page"] end
site()
click to toggle source
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 50 def site @context["site"] end
target!()
click to toggle source
This generates pretty output contrary to Jbuilder#target!.
# File lib/jekyll/geolexica/jbuilder_tag.rb, line 61 def target! JSON.pretty_generate(@builder.attributes!) end