Class: Twig::Node::Text

Inherits:
Base
  • Object
show all
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

#template_name

Constructor Details

#initialize(data, lineno = 0) ⇒ Text

Returns a new instance of Text.

Parameters:

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


8
9
10
# File 'lib/twig/node/text.rb', line 8

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

Instance Method Details

#compile(compiler) ⇒ Object



12
13
14
15
16
17
# File 'lib/twig/node/text.rb', line 12

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