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 Method Summary collapse
- #context ⇒ Object
- #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 Method Details
#context ⇒ Object
42 43 44 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 42 def context @context end |
#eval_source(source) ⇒ Object
54 55 56 57 58 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 54 def eval_source(source) instance_eval(source) rescue 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
46 47 48 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 46 def page @context["page"] end |
#site ⇒ Object
50 51 52 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 50 def site @context["site"] end |
#target! ⇒ Object
This generates pretty output contrary to Jbuilder#target!.
61 62 63 |
# File 'lib/jekyll/geolexica/jbuilder_tag.rb', line 61 def target! JSON.pretty_generate(@builder.attributes!) end |