Class: Fabulator::Template::Context

Inherits:
Radius::Context
  • Object
show all
Defined in:
lib/fabulator/template/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
13
14
15
# File 'lib/fabulator/template/context.rb', line 8

def initialize(parser)
  super()
  @parser = parser
  globals.context = @context
  parser.tags.each do |name|
    define_tag(name) { |tag_binding| parser.render_tag(name, tag_binding) }
  end
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/fabulator/template/context.rb', line 6

def context
  @context
end

Instance Method Details

#raise_errors?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fabulator/template/context.rb', line 17

def raise_errors?
  true
end

#render_tag(name, attributes = {}, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/fabulator/template/context.rb', line 21

def render_tag(name, attributes = {}, &block)
  binding = @tag_binding_stack.last
  locals = binding ? binding.locals : globals
  set_process_variables(locals.page)
  super
rescue Exception => e
  raise e if raise_errors?
  @tag_binding_stack.pop unless @tag_binding_stack.last == binding
  render_error_message(e.message)
end

#tag_missing(name, attributes = {}, &block) ⇒ Object



32
33
34
35
36
# File 'lib/fabulator/template/context.rb', line 32

def tag_missing(name, attributes = {}, &block)
  super
rescue Radius::UndefinedTagError => e
  raise StandardTags::TagError.new(e.message)
end