Skip to content

Commit 236b9e7

Browse files
committed
Feat: Support other languages in template tag handling the content as raw_text
1 parent 91fe275 commit 236b9e7

File tree

7 files changed

+1844
-1623
lines changed

7 files changed

+1844
-1623
lines changed

corpus/spec.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ Interpolations - Raw HTML (https://vuejs.org/v2/guide/syntax.html#Raw-HTML)
8585
(end_tag
8686
(tag_name))))
8787

88+
================================================================================
89+
Template: Ignore content if language tag is given
90+
================================================================================
91+
92+
<template lang="pug">
93+
div
94+
| Some {{ inner }} pug here.
95+
| Ignore <HTML /> <tags/> here
96+
</template>
97+
98+
--------------------------------------------------------------------------------
99+
100+
(component
101+
(template_element
102+
(start_tag
103+
(tag_name) (attribute (attribute_name) (quoted_attribute_value (attribute_value))))
104+
(raw_text) (end_tag (tag_name))))
105+
88106
================================================================================
89107
Interpolations - Attributes (https://vuejs.org/v2/guide/syntax.html#Attributes)
90108
================================================================================

grammar.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ module.exports = grammar({
4949
$.self_closing_tag,
5050
),
5151

52-
template_element: $ => seq(
53-
alias($.template_start_tag, $.start_tag),
54-
repeat($._node),
55-
$.end_tag,
52+
template_element: $ => choice(
53+
seq(
54+
alias($.template2_start_tag, $.start_tag),
55+
optional($.raw_text),
56+
$.end_tag,
57+
),
58+
seq(
59+
alias($.template_start_tag, $.start_tag),
60+
repeat($._node),
61+
$.end_tag,
62+
)
5663
),
5764

5865
script_element: $ => seq(
@@ -77,6 +84,12 @@ module.exports = grammar({
7784
template_start_tag: $ => seq(
7885
"<",
7986
alias($._template_start_tag_name, $.tag_name),
87+
">",
88+
),
89+
template2_start_tag: $ => seq(
90+
"<",
91+
alias($._template_start_tag_name, $.tag_name),
92+
$.attribute,
8093
repeat(choice($.attribute, $.directive_attribute)),
8194
">",
8295
),

src/grammar.json

Lines changed: 78 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)