Skip to content

Commit

Permalink
Feat: Support other languages in template tag handling the content as…
Browse files Browse the repository at this point in the history
… raw_text
  • Loading branch information
zealot128 committed Jul 11, 2021
1 parent 91fe275 commit 236b9e7
Show file tree
Hide file tree
Showing 7 changed files with 1,844 additions and 1,623 deletions.
18 changes: 18 additions & 0 deletions corpus/spec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ Interpolations - Raw HTML (https://vuejs.org/v2/guide/syntax.html#Raw-HTML)
(end_tag
(tag_name))))

================================================================================
Template: Ignore content if language tag is given
================================================================================

<template lang="pug">
div
| Some {{ inner }} pug here.
| Ignore <HTML /> <tags/> here
</template>

--------------------------------------------------------------------------------

(component
(template_element
(start_tag
(tag_name) (attribute (attribute_name) (quoted_attribute_value (attribute_value))))
(raw_text) (end_tag (tag_name))))

================================================================================
Interpolations - Attributes (https://vuejs.org/v2/guide/syntax.html#Attributes)
================================================================================
Expand Down
21 changes: 17 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ module.exports = grammar({
$.self_closing_tag,
),

template_element: $ => seq(
alias($.template_start_tag, $.start_tag),
repeat($._node),
$.end_tag,
template_element: $ => choice(
seq(
alias($.template2_start_tag, $.start_tag),
optional($.raw_text),
$.end_tag,
),
seq(
alias($.template_start_tag, $.start_tag),
repeat($._node),
$.end_tag,
)
),

script_element: $ => seq(
Expand All @@ -77,6 +84,12 @@ module.exports = grammar({
template_start_tag: $ => seq(
"<",
alias($._template_start_tag_name, $.tag_name),
">",
),
template2_start_tag: $ => seq(
"<",
alias($._template_start_tag_name, $.tag_name),
$.attribute,
repeat(choice($.attribute, $.directive_attribute)),
">",
),
Expand Down
95 changes: 78 additions & 17 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 236b9e7

Please sign in to comment.