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

{{if expr}} can error for certain expressions, or lead to repeated evaluation of expression. #11

Open
dvv opened this issue Oct 21, 2010 · 4 comments

Comments

@dvv
Copy link

dvv commented Oct 21, 2010

Hi!

I discovered the source of constant ReferenceError being thrown in my templates:
$.tmpl('{{if !user}}NOUSER{{/if}}', {}), though $.tmpl('{{if user}}USER{{/if}}', {}) works silently.

In the guts the first version compiles to ... if((typeof((!user))!=='undefined' && ((!user))!=null) && ... which of course requires user to be in the scope.

Couldn't we fix that (quite valid) case of branching, or at least put big fat warning on templates usage pattern?

TIA,
--Vladimir

@BorisMoore
Copy link
Owner

@BorisMoore
Copy link
Owner

{{if (!isEnabled())}} will work. But {{if false==isEnabled()}} will fail!

So yes, there are indeed some issues around automatic detection of null/undefined, and type function, for expression in {{if expression}}. We will be working on improvements in this area... See also issue 35

@BorisMoore
Copy link
Owner

@rdworth
Copy link
Contributor

rdworth commented Oct 8, 2011

Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.

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

No branches or pull requests

3 participants