Class: Twig::Node::Text

Inherits:
Base
  • Object
show all
Includes:
Output
Defined in:
lib/twig/node/text.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(data, lineno = 0) ⇒ Text

Returns a new instance of Text.

Parameters:

  • data (String)
  • lineno (Integer) (defaults to: 0)


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

def initialize(data, lineno = 0)
  super({}, { data: }, lineno)
end

Instance Method Details

#compile(compiler) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/twig/node/text.rb', line 14

def compile(compiler)
  compiler.
    add_debug_info(self).
    write('context.output_buffer.safe_append = ').
    string(attributes[:data]).
    raw(";\n")
end