I’m trying to write a syntax definition for our in-house templating language, it looks like this:
{% with teacher.Links as link %}
<div class="?"></div>
{% /with %}
{% with teacher.Links as link %}
<div class="?"></div>
{% /with %}
{% /end %}
My early attempts where rather succesful, until I started to incorporate the ide of a “tag body” in between {% start %}{% /end %}
tags. In the given example, I want it to recognize that {% /end %}
is a stray closing tag.
But after the first {% /with %}
, it doesn’t seem to recognize the next opener tag anymore.
Here is the crude sublime-syntax
I made:
contexts:
main:
- include: ijs
ijs:
- match: '{% (?!\/)'
scope: keyword.operator.delimiter.opener
push: tag
- match: '{% \/\w+ %}'
scope: invalid.illegal.stray-bracket-end
tag:
- match: '%}'
push: tag-body
tag-body:
- meta_scope: 'meta.ijs.tag.body'
- match: '{% \/\w+'
scope: entity.name.closer
set:
- match: '%}'
scope: keyword.operator.delimiter.body.closer
pop: true
I made many variations on this. My first attempt also included pushing Packages/HTML/HTML.sublime-syntax
and with_prototype
stuff, but because I couldn’t get it all to work I figured I would start with this basic thing, first.
So could anyone help me out here?
Edit:
I’ve had a bit of more luck with this code:
contexts:
main:
- match: ''
push: Packages/HTML/HTML.sublime-syntax
with_prototype:
- match: '{% '
scope: keyword.operator.delimiter.opener
push: body
- match: '{% \/\w+ %}'
scope: invalid.illegal.stray-bracket-end
body:
- meta_scope: hawkejs.body
- match: '%}'
scope: keyword.operator.delimiter.body.opener
push: Packages/HTML/HTML.sublime-syntax
with_prototype:
- match: '{% \/\w+ %}'
scope: keyword.operator.delimiter.hawk
pop: true
- match: '{% '
scope: keyword.operator.delimiter.opener
push: body
- match: '{% \/\w+ %}'
pop: true
But I seem to get stuck in multiple scopes, unable to break out.