Module: Amrita2::Extention::UseOriginalElement
Overview
Defined Under Namespace
Classes: Expander
Class Method Summary
collapse
Instance Method Summary
collapse
-
#code_for_element_with_child(element, dyn_spec, cg) ⇒ Object
-
#code_for_leaf_element(element, dyn_spec, cg, &block) ⇒ Object
-
#code_for_not_leaf_element(element, dyn_spec, cg, &block) ⇒ Object
-
#generate_expander(spec, mod, parent = nil) ⇒ Object
#check_option
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
Class Method Details
.check_option(spec, k, v) ⇒ Object
1547
1548
|
# File 'lib/amrita2/core.rb', line 1547
def self.check_option(spec, k, v)
end
|
Instance Method Details
#code_for_element_with_child(element, dyn_spec, cg) ⇒ Object
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
|
# File 'lib/amrita2/core.rb', line 1564
def code_for_element_with_child(element, dyn_spec, cg)
cg.code("yield(#{dyn_spec.module_name})")
cg.if_("get_substream(:#{dyn_spec.output_stream}).size == 0") do
cg.generate_static_element_code(element, dyn_spec.option) do
element.each_child do |e|
e.amrita_compile_main_code(cg)
end
end
cg.else_ do
cg.code("output_substream(:#{dyn_spec.name_for(element)})")
element.each_child do |e|
e.amrita_compile_main_code(cg)
end
cg.put_constant(end_tag(element))
end
end
end
|
#code_for_leaf_element(element, dyn_spec, cg, &block) ⇒ Object
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
|
# File 'lib/amrita2/core.rb', line 1550
def code_for_leaf_element(element, dyn_spec, cg, &block)
sym = dyn_spec.sym
cg.define_element_method(sym, dyn_spec.output_stream) do
cg.if_("block_given?") do
gen_element_with_attr(element, dyn_spec, cg)
cg.code("e.text = #{element.text.inspect}")
cg.code("get_mainstream << yield(e).to_s")
cg.else_ do
code_for_element_and_scalar(element, dyn_spec, cg)
end
end
end
end
|
#code_for_not_leaf_element(element, dyn_spec, cg, &block) ⇒ Object
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
|
# File 'lib/amrita2/core.rb', line 1582
def code_for_not_leaf_element(element, dyn_spec, cg, &block)
sym = dyn_spec.name_for(element)
cg.define_element_method(sym, dyn_spec.output_stream) do
code_for_element_with_child(element, dyn_spec, cg, &block)
end
cg.define_module(dyn_spec.module_name) do
cg.code("Methods = #{dyn_spec.get_methods.inspect}")
cg.code("include Amrita2")
cg.code("extend Amrita2")
cg.define_method(sym, "val=nil", "attrs={}") do
cg.new_context("get_substream(:#{sym})") do
cg.code("e = yield(new_element(#{element.name.inspect}))")
cg.code("get_mainstream << start_tag(e)")
end
yield
end
end
end
|
#generate_expander(spec, mod, parent = nil) ⇒ Object
1618
1619
1620
|
# File 'lib/amrita2/core.rb', line 1618
def generate_expander(spec, mod, parent=nil)
Expander.new(parent, spec, mod)
end
|