Class: Amrita2::Expander::Base

Inherits:
Object
  • Object
show all
Includes:
Runtime
Defined in:
lib/amrita2/core.rb

Overview

:nodoc:

Direct Known Subclasses

Leaf, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Runtime

#context_stack, #current_context, #end_tag, #get_binding, #get_context_data, #get_mainstream, #get_substream, #new_binding, #new_context, #new_context_data, #new_element, #output_substream, #set_binding, #set_context_data, #start_tag

Constructor Details

#initialize(parent, spec, pmod) ⇒ Base

Returns a new instance of Base.



1357
1358
1359
1360
1361
1362
1363
# File 'lib/amrita2/core.rb', line 1357

def initialize(parent, spec, pmod)
  @parent = parent
  @spec = spec
  @children = []
  @name = @spec.sym
  @method = pmod.method(@spec.sym || :expand_template) unless spec.option[:dummy_element]
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



1356
1357
1358
# File 'lib/amrita2/core.rb', line 1356

def children
  @children
end

#modObject (readonly)

Returns the value of attribute mod.



1356
1357
1358
# File 'lib/amrita2/core.rb', line 1356

def mod
  @mod
end

#nameObject (readonly)

Returns the value of attribute name.



1356
1357
1358
# File 'lib/amrita2/core.rb', line 1356

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



1356
1357
1358
# File 'lib/amrita2/core.rb', line 1356

def parent
  @parent
end

#specObject (readonly)

Returns the value of attribute spec.



1356
1357
1358
# File 'lib/amrita2/core.rb', line 1356

def spec
  @spec
end

Instance Method Details

#call_template_method(data = nil, context_data = data, attrs = nil, &block) ⇒ Object



1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
# File 'lib/amrita2/core.rb', line 1365

def call_template_method(data=nil, context_data=data, attrs=nil, &block)
  args = [data]
  args << attrs if attrs
  if @spec.option[:eval_cdata_as_erb] and context_data
    new_context_data(context_data) do
      @method.call(*args, &block)
    end
  else
    @method.call(*args, &block)
  end
end