Class: Twig::Node::Expression::Filter::Raw

Inherits:
Twig::Node::Expression::Filter show all
Defined in:
lib/twig/node/expression/filter/raw.rb

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(node, filter = nil, arguments = nil, lineno = nil) ⇒ Raw

Returns a new instance of Raw.

Parameters:



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

def initialize(node, filter = nil, arguments = nil, lineno = nil)
  super(
    node,
    filter || TwigFilter.new('raw', nil, { is_safe: [:all] }),
    arguments || Node::Empty.new,
    lineno || node.lineno
  )
end

Instance Method Details

#compile(compiler) ⇒ Object



21
22
23
24
25
26
# File 'lib/twig/node/expression/filter/raw.rb', line 21

def compile(compiler)
  compiler.
    raw('((tmp = ').
    subcompile(nodes[:node]).
    raw(').respond_to?(:html_safe) ? tmp.html_safe : tmp)')
end