Class: Twig::TokenParser::With
- Defined in:
- lib/twig/token_parser/with.rb
Overview
Creates a nested scope
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Instance Method Details
#parse(token) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/twig/token_parser/with.rb', line 7 def parse(token) stream = parser.stream variables = nil only = false unless stream.test(Token::BLOCK_END_TYPE) variables = parser.parse_expression only = !stream.next_if(Token::NAME_TYPE, 'only').nil? end stream.expect(Token::BLOCK_END_TYPE) body = parser.subparse(method(:decide_with_end), drop_needle: true) stream.expect(Token::BLOCK_END_TYPE) Node::With.new(body, variables, only, token.lineno) end |
#tag ⇒ Object
25 26 27 |
# File 'lib/twig/token_parser/with.rb', line 25 def tag 'with' end |