Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix named block #15

Merged
merged 2 commits into from
Dec 29, 2023
Merged

fix named block #15

merged 2 commits into from
Dec 29, 2023

Conversation

patricklx
Copy link
Collaborator

@patricklx patricklx commented Dec 29, 2023

the regex \b:custom\b wasn't able to match the tag name...
https://regex101.com/r/U2MlJe/2

Copy link

stackblitz bot commented Dec 29, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@@ -267,12 +267,12 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
let start = n.range[0];
let codeSlice = code.slice(...n.range);
for (const part of n.tag.split('.')) {
const regex = new RegExp(`\\b${part}\\b`);
let pattern = `\\b${part}\\b`;
if (part.startsWith(':')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the significance of the leading \b vs not?

Copy link
Collaborator Author

@patricklx patricklx Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\b is only an assertion that we are at a word boundary. so either before or after there is a word character and at the other side there is a non-word character (special character).
But with named block, we are not at a word boundary since there are no word characters at the beginning. : is not a word character. but with : we are sure that we match the correct part

@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Dec 29, 2023
NullVoxPopuli
NullVoxPopuli previously approved these changes Dec 29, 2023
Copy link
Member

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing yesterday 😅


const name = n?.name ?? n.tag;

if (htmlTags.includes(name)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's possible to override plain html tags with block params

@patricklx patricklx merged commit 58d18b8 into main Dec 29, 2023
5 checks passed
@patricklx patricklx deleted the fix-named-block branch December 29, 2023 14:02
@github-actions github-actions bot mentioned this pull request Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants