Class: Twig::Node::Expression::Parent

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

Overview

Represents a parent node

Instance Attribute Summary

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from Base

#explicit_parentheses?, #set_explicit_parentheses

Methods inherited from Base

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

Constructor Details

#initialize(name, lineno) ⇒ Parent

Returns a new instance of Parent.

Parameters:

  • name (String)
  • lineno (Integer)


10
11
12
# File 'lib/twig/node/expression/parent.rb', line 10

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

Instance Method Details

#compile(compiler) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twig/node/expression/parent.rb', line 14

def compile(compiler)
  if attributes[:output]
    compiler.add_debug_info(self)
    raise NotImplementedError
  else
    compiler.
      raw('render_parent_block(').
      string(attributes[:name]).
      raw(', context, blocks)')
  end
end