Class: Twig::ExpressionParser::Infix::Filter

Inherits:
Twig::ExpressionParser::InfixExpressionParser show all
Includes:
ParsesArguments
Defined in:
lib/twig/expression_parser/infix/filter.rb

Constant Summary

Constants inherited from Twig::ExpressionParser::InfixExpressionParser

Twig::ExpressionParser::InfixExpressionParser::LEFT, Twig::ExpressionParser::InfixExpressionParser::RIGHT

Instance Method Summary collapse

Methods inherited from Twig::ExpressionParser::InfixExpressionParser

#left?, #right?, #type

Methods inherited from Base

#aliases, #to_s, #type

Instance Method Details

#associativityObject



37
38
39
# File 'lib/twig/expression_parser/infix/filter.rb', line 37

def associativity
  LEFT
end

#descriptionObject



29
30
31
# File 'lib/twig/expression_parser/infix/filter.rb', line 29

def description
  'Twig filter call'
end

#nameObject



25
26
27
# File 'lib/twig/expression_parser/infix/filter.rb', line 25

def name
  '|'
end

#parse(parser, left, _token) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/twig/expression_parser/infix/filter.rb', line 9

def parse(parser, left, _token)
  stream = parser.stream
  token = stream.expect(Token::NAME_TYPE)
  line = token.lineno

  arguments = if stream.test(Token::OPERATOR_TYPE, '(')
                parse_named_arguments(parser)
              else
                Node::Empty.new
              end

  filter = parser.filter(token.value, line)

  filter.node_class.new(left, filter, arguments, token.lineno)
end

#precedenceObject



33
34
35
# File 'lib/twig/expression_parser/infix/filter.rb', line 33

def precedence
  300
end