Class: Jekyll::Geolexica::JbuilderTag::JbuilderWrapper
- Inherits:
-
Object
- Object
- Jekyll::Geolexica::JbuilderTag::JbuilderWrapper
- Defined in:
- lib/jekyll/geolexica/jbuilder_tag.rb
Overview
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.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #eval_source(source) ⇒ Object
-
#initialize(context) ⇒ JbuilderWrapper
constructor
A new instance of JbuilderWrapper.
- #json ⇒ Object
- #page ⇒ Object
- #site ⇒ Object
-
#target! ⇒ Object
This generates pretty output contrary to Jbuilder#target!.
Constructor Details
#initialize(context) ⇒ JbuilderWrapper
Returns a new instance of JbuilderWrapper.
33 34 35 36 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 33 def initialize(context) @builder = Jbuilder.new @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
42 43 44 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 42 def context @context end |
Instance Method Details
#eval_source(source) ⇒ Object
52 53 54 55 56 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 52 def eval_source(source) instance_eval(source) rescue StandardError raise Error.new(source) end |
#json ⇒ Object
38 39 40 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 38 def json @builder end |
#page ⇒ Object
44 45 46 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 44 def page @context["page"] end |
#site ⇒ Object
48 49 50 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 48 def site @context["site"] end |
#target! ⇒ Object
This generates pretty output contrary to Jbuilder#target!.
59 60 61 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 59 def target! JSON.pretty_generate(@builder.attributes!) end |