Skip to content

Commit ba39576

Browse files
authored
Merge pull request #88 from jsit/ember-angle-brackets
Add Ember angle bracket syntax
2 parents f25a4c3 + 47bdf0c commit ba39576

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

example.mustache

+14
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@
130130
{{/if}}
131131
<!-- end indentation tests -->
132132

133+
<AngleBracketComponent
134+
@mustache={{@bla}}
135+
@number=123
136+
data-test-id="test"
137+
class="my-class" as |test|>
138+
Some Text
139+
<div>{{test.someValue}}</div>
140+
<test.component teste="asdfads"></test.component>
141+
</AngleBraketComponent>
142+
143+
<HelloAngleBrackets @prop={{test}} />
144+
145+
<MyInput type="text" oninput={{action (mut fooBar) value="target.value"}} />
146+
133147
</div>
134148

135149
</body>

syntax/mustache.vim

+32-17
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
" Language: Mustache, Handlebars
33
" Maintainer: Juvenn Woo <[email protected]>
44
" Screenshot: http://imgur.com/6F408
5-
" Version: 5
6-
" Last Change: Nov 23rd 2018
5+
" Version: 6
6+
" Last Change: Jul 16 2019
77
" Remark:
88
" It lexically hilights embedded mustaches (exclusively) in html file.
99
" While it was written for Ruby-based Mustache template system, it should
@@ -41,21 +41,34 @@ endif
4141

4242
syntax match mustacheError '}}}\?'
4343
syntax match mustacheInsideError '{{[{$#<>=!\/]\?'
44-
syntax region mustacheInside start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
45-
syntax match mustacheOperators '=\|\.\|/' contained containedin=mustacheInside,mustacheParam
46-
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=mustacheInside
47-
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer
48-
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=mustacheInside,@htmlMustacheContainer
49-
syntax match mustacheHandlebars '{{\|}}' contained containedin=mustacheInside,@htmlMustacheContainer
50-
syntax match mustacheUnescape '{{{\|}}}' contained containedin=mustacheInside,@htmlMustacheContainer
51-
syntax match mustacheConditionals '\([/#]\?if\|unless\|else\)' contained containedin=mustacheInside
52-
syntax match mustacheHelpers '[/#]\?\(with\|link\-to\|each\(\-in\)\?\)' contained containedin=mustacheInside
53-
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=mustacheInside
54-
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=mustacheInside
55-
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,mustacheInside,@htmlMustacheContainer
56-
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,mustacheInside,@htmlMustacheContainer
57-
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=mustacheInside
58-
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=mustacheInside
44+
45+
" Ember angle bracket syntax syntax starts with a capital letter:
46+
" https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md
47+
syntax case match
48+
syntax region mustacheAngleComponent start=/<\/\?[[:upper:]]/ end=/>/ keepend containedin=TOP,@htmlMustacheContainer
49+
syntax case ignore
50+
syntax match mustacheAngleBrackets '</\?\|/\?>' contained containedin=mustacheAngleComponent
51+
syntax match mustacheAngleComponentName '</[[:alnum:]]\+'hs=s+2 contained containedin=mustacheAngleBrackets
52+
syntax match mustacheAngleComponentName '<[[:alnum:]]\+'hs=s+1 contained containedin=mustacheAngleBrackets
53+
54+
syntax region mustacheHbsComponent start=/{{[^!][$#^/]\?/ end=/}}}\?/ keepend containedin=TOP,@htmlMustacheContainer
55+
56+
syntax cluster mustacheInside add=mustacheHbsComponent,mustacheAngleComponent
57+
58+
syntax match mustacheOperators '=\|\.\|/^>' contained containedin=@mustacheInside,mustacheParam
59+
syntax region mustacheHtmlValue start=/={{[^!][$#^/]\?/rs=s+1,hs=s+1 end=/}}/ oneline keepend contained containedin=htmlTag contains=@mustacheInside
60+
syntax region mustachePartial start=/{{[<>]/lc=2 end=/}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
61+
syntax region mustacheMarkerSet start=/{{=/lc=2 end=/=}}/me=e-2 contained containedin=@mustacheInside,@htmlMustacheContainer
62+
syntax match mustacheHandlebars '{{\|}}' contained containedin=@mustacheInside
63+
syntax match mustacheUnescape '{{{\|}}}' contained containedin=@mustacheInside
64+
syntax match mustacheConditionals '\([/#]\?if\|unless\|else\)' contained containedin=@mustacheInside
65+
syntax match mustacheHelpers '[/#]\?\(with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside
66+
syntax match mustacheHelpers 'else \(if\|unless\|with\|link\-to\|each\(\-in\)\?\)' contained containedin=@mustacheInside
67+
syntax match mustacheParam /[a-z@_-]\+=/he=e-1 contained containedin=@mustacheInside
68+
syntax region mustacheComment start=/{{!/rs=s+2 skip=/{{.\{-}}}/ end=/}}/re=e-2 contains=Todo contained containedin=TOP,@mustacheInside,@htmlMustacheContainer
69+
syntax region mustacheBlockComment start=/{{!--/rs=s+2 skip=/{{.\{-}}}/ end=/--}}/re=e-2 contains=Todo contained extend containedin=TOP,@mustacheInside,@htmlMustacheContainer
70+
syntax region mustacheQString start=/'/ skip=/\\'/ end=/'/ contained containedin=@mustacheInside
71+
syntax region mustacheDQString start=/"/ skip=/\\"/ end=/"/ contained containedin=@mustacheInside
5972

6073
" Clustering
6174
syntax cluster htmlMustacheContainer add=htmlHead,htmlTitle,htmlString,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,htmlLink,htmlBold,htmlUnderline,htmlItalic,htmlValue
@@ -69,13 +82,15 @@ HtmlHiLink mustacheVariableUnescape Number
6982
HtmlHiLink mustachePartial Number
7083
HtmlHiLink mustacheMarkerSet Number
7184
HtmlHiLink mustacheParam htmlArg
85+
HtmlHiLink mustacheAngleComponentName htmlTag
7286

7387
HtmlHiLink mustacheComment Comment
7488
HtmlHiLink mustacheBlockComment Comment
7589
HtmlHiLink mustacheError Error
7690
HtmlHiLink mustacheInsideError Error
7791

7892
HtmlHiLink mustacheHandlebars Special
93+
HtmlHiLink mustacheAngleBrackets htmlTagName
7994
HtmlHiLink mustacheUnescape Identifier
8095
HtmlHiLink mustacheOperators Operator
8196
HtmlHiLink mustacheConditionals Conditional

0 commit comments

Comments
 (0)