Class: Roger::Template::TemplateContext

Inherits:
Object
  • Object
show all
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

Methods included from Helpers::Rendering

#render_file

Methods included from Helpers::Partial

#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

#documentObject

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

#envObject

The current environment variables.



33
34
35
# File 'lib/roger/template/template_context.rb', line 33

def env
  @_env
end

#rendererObject



18
19
20
# File 'lib/roger/template/template_context.rb', line 18

def renderer
  @_renderer
end

#templateObject

The current Roger::Template in use



23
24
25
# File 'lib/roger/template/template_context.rb', line 23

def template
  @_renderer.current_template
end