Class: Twig::Node::Block

Inherits:
Base
  • Object
show all
Defined in:
lib/twig/node/block.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #lineno, #nodes, #source_context, #tag

Instance Method Summary collapse

Methods inherited from Base

#empty?, #length, #template_name, #to_s

Constructor Details

#initialize(name, body, lineno) ⇒ Block

Returns a new instance of Block.



6
7
8
# File 'lib/twig/node/block.rb', line 6

def initialize(name, body, lineno)
  super({ body: }, { name: }, lineno)
end

Instance Method Details

#compile(compiler) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/twig/node/block.rb', line 10

def compile(compiler)
  compiler.
    add_debug_info(self).
    write("def block_#{attributes[:name]}(context, blocks)\n").
    indent.
    write("macros = @macros.dup\n").
    subcompile(nodes[:body]).
    outdent.
    write("end\n\n")
end