From 89b93e2b5568167020fb8e0372ca50a0f5003a18 Mon Sep 17 00:00:00 2001 From: Koen Lageveen Date: Mon, 29 Jul 2024 18:41:04 +0200 Subject: [PATCH] allow chaining of tests with other logic --- resources/syntax/Twig.sublime-syntax | 2 ++ resources/syntax/tests/syntax_test_html.twig | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/resources/syntax/Twig.sublime-syntax b/resources/syntax/Twig.sublime-syntax index e135485..d363607 100644 --- a/resources/syntax/Twig.sublime-syntax +++ b/resources/syntax/Twig.sublime-syntax @@ -234,6 +234,8 @@ contexts: tests_body: - meta_scope: meta.function.test.twig - include: block_pop + - match: (?=\b(and|or|b-and|b-or|b-xor)\b) + pop: 1 # builtin tests - match: '\bnot\b' scope: keyword.operator.word.logical.twig diff --git a/resources/syntax/tests/syntax_test_html.twig b/resources/syntax/tests/syntax_test_html.twig index d407c02..8cc05e6 100644 --- a/resources/syntax/tests/syntax_test_html.twig +++ b/resources/syntax/tests/syntax_test_html.twig @@ -577,6 +577,19 @@ | ^^^ support.function.test.twig | ^^ punctuation.definition.expression.end.twig +{{ name is odd and name != '' }} +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.expression.twig +|^ punctuation.definition.expression.begin.twig +| ^ - variable.function.test.twig + +{% if loop.index is divisible by(3) and foo == bar %}{% endif %} +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.twig +| ^^ keyword.operator.comparison.test.twig +| ^^^^^^^^^^^^ support.function.test.twig +| ^^^ meta.function-call.arguments.twig +| ^ constant.numeric.value.twig +| ^^^ variable.other.twig + {# Custom test #} {{ name is weird }} | ^^ keyword.operator.comparison.test.twig