Skip to content

Commit 8c04194

Browse files
committed
Add support for HAML templates
Resolves vuejs/vue-syntax-highlight#202 This commit adds support for HAML syntax highlighting between `<template>` tags.
1 parent 30efda3 commit 8c04194

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

Vue Component.sublime-syntax

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,11 @@ contexts:
627627
- include: template-lang-decider
628628

629629
template-lang-decider:
630+
- match: (?i)(?=haml{{unquoted_attribute_break}}|\'haml\'|"haml")
631+
set:
632+
- template-haml
633+
- tag-lang-attribute-meta
634+
- tag-generic-attribute-value
630635
- match: (?i)(?=jade{{unquoted_attribute_break}}|\'jade\'|"jade")
631636
set:
632637
- template-jade
@@ -648,6 +653,20 @@ contexts:
648653
- tag-lang-attribute-meta
649654
- tag-generic-attribute-value
650655

656+
template-haml:
657+
- meta_scope: meta.tag.template.begin.html
658+
- match: '>'
659+
scope: punctuation.definition.tag.end.html
660+
set: template-haml-content
661+
- include: template-common
662+
663+
template-haml-content:
664+
- match: '{{template_content_begin}}'
665+
embed: scope:text.haml
666+
embed_scope: text.haml.embedded.html
667+
escape: '{{template_content_end}}'
668+
pop: 1
669+
651670
template-jade:
652671
- meta_scope: meta.tag.template.begin.html
653672
- match: '>'

tests/syntax_test_template.vue

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@
1212
// <- text.html.vue - text text
1313
// ^^^^^^^^^^^ meta.tag.template.end.html
1414

15+
<!--
16+
HAML Template Tests
17+
-->
18+
19+
<template lang="haml">
20+
// ^^^^^^^^^^ meta.tag - meta.tag meta.tag - meta.attribute-with-value
21+
// ^^^^^^^^^^^ meta.tag meta.attribute-with-value.lang.html - meta.tag meta.tag
22+
// ^ meta.tag.template.begin.html - meta.tag meta.tag
23+
// ^ punctuation.definition.tag.begin.html
24+
// ^^^^^^^^ entity.name.tag.template.html
25+
// ^^^^ entity.other.attribute-name.html
26+
// ^ punctuation.separator.key-value.html
27+
// ^ punctuation.definition.tag.end.html
28+
29+
// <- text.haml.embedded.html
30+
</template>
31+
// ^^^^^^^^^^^ meta.tag - meta.tag meta.tag - text.haml
32+
// ^^ punctuation.definition.tag.begin.html
33+
// ^^^^^^^^ entity.name.tag.template.html
34+
// ^ punctuation.definition.tag.end.html
35+
36+
<!--
37+
Jade Template Tests
38+
-->
39+
1540
<template lang="jade"> foo </template>
1641
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag - source
1742
// ^^^^^ text.jade.embedded.html - meta.tag
@@ -32,7 +57,6 @@
3257
// ^^^^^^^^^^^^^^ text.jade.embedded.html - meta.tag - comment
3358
// ^^^^^^^^^^^ meta.tag - source
3459

35-
3660
<template lang="jade">
3761

3862
// <- text.jade.embedded.html
@@ -58,6 +82,10 @@
5882
// ^^^^^^^^ entity.name.tag.template.html
5983
// ^ punctuation.definition.tag.end.html
6084

85+
<!--
86+
Pug Template Tests
87+
-->
88+
6189
<template lang="pug">
6290
// ^^^^^^^^^^ meta.tag - meta.tag meta.tag - meta.attribute-with-value
6391
// ^^^^^^^^^^ meta.tag meta.attribute-with-value.lang.html - meta.tag meta.tag
@@ -75,6 +103,10 @@
75103
// ^^^^^^^^ entity.name.tag.template.html
76104
// ^ punctuation.definition.tag.end.html
77105

106+
<!--
107+
Slim Template Tests
108+
-->
109+
78110
<template lang="slm">
79111
// ^^^^^^^^^^ meta.tag - meta.tag meta.tag - meta.attribute-with-value
80112
// ^^^^^^^^^^ meta.tag meta.attribute-with-value.lang.html - meta.tag meta.tag

0 commit comments

Comments
 (0)