Skip to content

Component regex tries to match commented out code #102

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

Closed
Archmonger opened this issue Oct 13, 2022 · 0 comments · Fixed by #106
Closed

Component regex tries to match commented out code #102

Archmonger opened this issue Oct 13, 2022 · 0 comments · Fixed by #106

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Oct 13, 2022

Current Situation

Currently commented out component tags will attempt to be parsed by our component regex.

For example, this should not be parsed <!-- {% component "my.component" %} -->

Proposed Actions

Modify the regex to avoid any tags within comments.

As a quick test, I attempted to see what would happen if I prefixed the component regex with a negative lookbehind (?<!(<!--))\s*, however, it did not work for any tags containing a space between the comment start <!-- and tag start {%

Additionally, I'm not entirely how to write regex for situations like <!-- {% component "my.component" %} --> while not hitting false negatives for things such as <!-- a comment --> {% component "my.component" %} <!-- another comment -->

If a regex solution can't be made, a quick and dirty solution could be running some kind of HTML minifier to strip out comment tags prior to reading the template HTML.

Or a running a simple regex replace on all comments prior to parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant