Skip to content

Commit

Permalink
fix tags from args (@ prefix)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 29, 2023
1 parent d60515b commit e1314df
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/parser/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,8 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
let start = n.range[0];
let codeSlice = code.slice(...n.range);
for (const part of n.tag.split('.')) {
let pattern = `\\b${part}\\b`;
if (part.startsWith(':')) {
pattern = `${part}\\b`;
}
const regex = new RegExp(pattern);
const match = codeSlice.match(regex);
const range = [start + match.index, 0];
const idx = codeSlice.indexOf(part);
const range = [start + idx, 0];
range[1] = range[0] + part.length;
codeSlice = code.slice(range[1], n.range[1]);
start = range[1];
Expand All @@ -295,8 +290,11 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
n.params = [];
}
if ('blockParams' in n && n.parent) {
let part = code.slice(...n.parent.range);
let start = n.parent.range[0];
// for blocks {{x as |b|}} the block range does not contain the block params...
// for element tag it does <x as b />
const blockRange = n.type === 'block' ? n.parent.range : n.range;
let part = code.slice(...blockRange);
let start = blockRange[0];
let idx = part.indexOf('|') + 1;
start += idx;
part = part.slice(idx, -1);
Expand Down Expand Up @@ -439,6 +437,7 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
if (
n.name !== 'this' &&
!n.name.startsWith(':') &&
!n.name.startsWith('@') &&
scope &&
(variable ||
isUpperCase(n.name[0]) ||
Expand Down

0 comments on commit e1314df

Please sign in to comment.