Skip to content

Commit 49dd14c

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

File tree

7 files changed

+1655
-1440
lines changed

7 files changed

+1655
-1440
lines changed

corpus/spec.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,54 @@ 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)
105+
(end_tag (tag_name))
106+
)
107+
)
108+
109+
================================================================================
110+
Template: Ignore content if language tag is given, template close is found
111+
================================================================================
112+
113+
<template lang="pug">
114+
.doodle-wrapper
115+
hidden-field-set(:form-name="formName" :values="hiddenAttributes")
116+
simple-page-wrapper(:pages="pages")
117+
118+
</template>
119+
120+
<script lang="ts">
121+
</script>
122+
123+
--------------------------------------------------------------------------------
124+
125+
(component
126+
(template_element
127+
(start_tag
128+
(tag_name) (attribute (attribute_name) (quoted_attribute_value (attribute_value))))
129+
(raw_text) (end_tag (tag_name)))
130+
(script_element
131+
(start_tag
132+
(tag_name) (attribute (attribute_name) (quoted_attribute_value (attribute_value))))
133+
(raw_text) (end_tag (tag_name)))
134+
)
135+
88136
================================================================================
89137
Interpolations - Attributes (https://vuejs.org/v2/guide/syntax.html#Attributes)
90138
================================================================================

grammar.js

Lines changed: 17 additions & 5 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,7 +84,12 @@ module.exports = grammar({
7784
template_start_tag: $ => seq(
7885
"<",
7986
alias($._template_start_tag_name, $.tag_name),
80-
repeat(choice($.attribute, $.directive_attribute)),
87+
">",
88+
),
89+
template2_start_tag: $ => seq(
90+
"<",
91+
alias($._template_start_tag_name, $.tag_name),
92+
repeat1(choice($.attribute, $.directive_attribute)),
8193
">",
8294
),
8395

src/grammar.json

Lines changed: 75 additions & 18 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)