Class: Twig::Node::Capture

Inherits:
Base
  • Object
show all
Defined in:
lib/twig/node/capture.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(body, lineno) ⇒ Capture

Returns a new instance of Capture.

Parameters:



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

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

Instance Method Details

#compile(compiler) ⇒ Object



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

def compile(compiler)
  compiler.
    raw("context.buffer_and_return do\n").
    indent.
    subcompile(nodes[:body]).
    outdent.
    write("end.to_s.html_safe\n")
end