-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Unable to start an expression with '/' #5318
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
Comments
I don't really see an easy way around this, You can also solve this just by wrapping in parens, the following both work fine: <div>{ (/^[A-Za-z ]+$/.test('Some String value') ? 'foo' : 'bar') }</div> <div>{ (/^[A-Za-z ]+$/).test('Some String value') ? 'foo' : 'bar' }</div> |
I'm labeling this as a docs issue, because I really don't think we want to try parsing this differently. That said, I'm not actually sure where in the docs this should go, or whether it even makes sense to mention, as it seems to have a high ratio of expected-confusion-caused-by-reading-this-explanation to expected-confusion-caused-by-running-into-this-limitation. |
I somewhat expected this to happen with all expressions, but |
Yeah it is i think. The issue is that we can't easily disambiguate between a closing blog |
Describe the bug
Using a regex in an expression lead to parsing error:
that's because the parser treat
{ /
as the closing of the logic block, eg:{/if}
.parsing the mustache as expression should have higher priority than parsing it as a closing logic block, eg:
{/if}
,{/await}
or{/each}
.Severity
A workaround is to not start the expression with
/
, replace it with a variable if possible, for the example above a workaround would be:Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: