Skip to content

Commit

Permalink
added rest param to tag() and modified _else_if_tag accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
este36 committed Nov 12, 2024
1 parent c18c7d8 commit 9ff82dc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,10 @@ module.exports = grammar(HTML, {
'}',
),

// Since 'else' and 'if' are separated by space, we cannot put them in a simple tag() like $._else_tag or $._if_start_tag
else_if_tag: $ => seq(
tag(':', 'else'),
field('tag', 'if'),
),
_else_if_tag: _ => tag(':', 'else', 'if'),
else_if_start: $ => seq(
'{',
alias($.else_if_tag, $.block_tag),
alias($._else_if_tag, $.block_tag),
field('condition', $.svelte_raw_text),
'}',
),
Expand Down Expand Up @@ -312,11 +308,13 @@ module.exports = grammar(HTML, {
/**
* @param {string} sym
* @param {string} text
* @rest param {string} ...other
* @return {SeqRule}
*/
function tag(sym, text) {
function tag(sym, text, ...other) {
return seq(
sym,
field('tag', token.immediate(text)),
...other.map(rule => field('tag', rule)),
);
}

0 comments on commit 9ff82dc

Please sign in to comment.