Sublime Forum

Syntax for multi line ifs not supported?

#1

Hi, I’m a bit confused by this topic Match multiple lines in .sublime-syntax
also I’ve checked eg js syntax file and found out that if and else kind of compleately independent…

I’m trying to write syntax for my tpl engine. Example:

<div>
    @if foo {
        <span>@boo</span>
    }
    else {
        Nope.
    }
</div>

What I need is to express that if “else” goes after if block(even on new line) its a part of tpl and not a markup. But match seems not matches new line symbils with \s.

0 Likes

#2

although it’s not possible to write a regex in .sublime-syntax files that will match across line boundaries, one can use contexts to achieve this. When you hit the } that ends the if, if the next non-whitespace token is else, proceed otherwise pop the context.

0 Likes

#3

Set with multiple contexts work nice. Thx.

0 Likes