Class: Roger::Template::TemplateContext
- Inherits:
-
Object
- Object
- Roger::Template::TemplateContext
- Includes:
- Helpers::Capture, Helpers::Partial, Helpers::Rendering
- Defined in:
- lib/roger/template/template_context.rb
Overview
The context that is passed to all templates
Instance Method Summary collapse
-
#document ⇒ Object
Access to the front-matter of the document (if any).
-
#env ⇒ Object
The current environment variables.
-
#initialize(renderer, env = {}) ⇒ TemplateContext
constructor
A new instance of TemplateContext.
- #renderer ⇒ Object
-
#template ⇒ Object
The current Roger::Template in use.
Methods included from Helpers::Rendering
Methods included from Helpers::Partial
Methods included from Helpers::Capture
#_content_for_blocks, #capture, #content_for, #content_for?, included
Constructor Details
#initialize(renderer, env = {}) ⇒ TemplateContext
Returns a new instance of TemplateContext.
13 14 15 16 |
# File 'lib/roger/template/template_context.rb', line 13 def initialize(renderer, env = {}) @_renderer = renderer @_env = env end |
Instance Method Details
#document ⇒ Object
Access to the front-matter of the document (if any)
28 29 30 |
# File 'lib/roger/template/template_context.rb', line 28 def document @_data ||= OpenStruct.new(@_renderer.data) end |
#env ⇒ Object
The current environment variables.
33 34 35 |
# File 'lib/roger/template/template_context.rb', line 33 def env @_env end |
#renderer ⇒ Object
18 19 20 |
# File 'lib/roger/template/template_context.rb', line 18 def renderer @_renderer end |
#template ⇒ Object
The current Roger::Template in use
23 24 25 |
# File 'lib/roger/template/template_context.rb', line 23 def template @_renderer.current_template end |