Class: Rtpl
- Inherits:
-
Object
- Object
- Rtpl
- Defined in:
- lib/rtpl.rb,
lib/rtpl/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.0.0'
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#parsed_blocks ⇒ Object
readonly
Returns the value of attribute parsed_blocks.
-
#vars ⇒ Object
readonly
Returns the value of attribute vars.
Instance Method Summary collapse
- #assign(key, value) ⇒ Object
-
#initialize(template) ⇒ Rtpl
constructor
A new instance of Rtpl.
- #out(key = "main") ⇒ Object
- #parse(block_name) ⇒ Object
Constructor Details
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
9 10 11 |
# File 'lib/rtpl.rb', line 9 def ast @ast end |
#parsed_blocks ⇒ Object (readonly)
Returns the value of attribute parsed_blocks.
9 10 11 |
# File 'lib/rtpl.rb', line 9 def parsed_blocks @parsed_blocks end |
#vars ⇒ Object (readonly)
Returns the value of attribute vars.
9 10 11 |
# File 'lib/rtpl.rb', line 9 def vars @vars end |
Instance Method Details
#assign(key, value) ⇒ Object
20 21 22 |
# File 'lib/rtpl.rb', line 20 def assign(key, value) @vars[key] = value end |
#out(key = "main") ⇒ Object
37 38 39 |
# File 'lib/rtpl.rb', line 37 def out(key = "main") @parsed_blocks[key].to_s end |
#parse(block_name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rtpl.rb', line 24 def parse(block_name) if block_name =~ /\./ @sub_blocks = true @parsed_blocks[block_name] += nested_output(@transform.apply(sub_block(block_name), :vars => @vars), block_name) else @parsed_blocks[block_name] += block_output(@transform.apply(@ast, :vars => @vars). detect{|b| b[:open][:name] == block_name }) end end |