-
Notifications
You must be signed in to change notification settings - Fork 1k
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
{{if conditionalProperty1 || conditionalProperty2}} fails #70
Comments
That is because you are passing a javascript expression containing variables which may be undefined. The template engine can check if you pass a single variable that is undefined: if conditional1, but cannot help the javascript engine to figure what to do with an expression that contains undefined variables within it: if conditional1 || conditional2. So the solution is either:
or use this for you data:
|
It seems rather counter-intuitive to repeat the same 'Success' content twice, especially with extensive markup. There are two reasons why this should work as expected:
I've forked the project, so I'll take a look this weekend. Besides this small issue, the entire project is nothing short of amazing. I can't even begin to imagine how many hours I've saved using it :) |
Sure, you would use
So if ( foo ) is a valid expression but will still throw... The only alternative is for the tmpl implementation to wrap things in try catch blocks. We'll be looking at this kind of possibility for better error handling in a future (Beta2) release... |
Right, that makes much more sense. I get where you're coming from now, but shouldn't all variables in a template be resolved against the current data object? That is,
Should automatically be interpreted as
I guess the cleanest way to implement this would be
Initiating the template like so
|
You can provide the hasConditional function on $item, as you suggest, yes, or you can include $data.conditional in your template, or you can ensure conditional1 and conditional2 are defined (true or false) on your data... But the template engine can't tell the JavaScript interpreter to interpret |
True, the parsing of expressions to search for identifiers should be kept well out of scope. I'll use the $item extension instead, much more readable :) Thanks Boris! |
Given the following template data:
These two both work
However, this silently fails and nothing is rendered
I've only been able to get this to work so far through the use of $data
The text was updated successfully, but these errors were encountered: