BorisMoore / jquery-tmpl

The original official jQuery Templates plugin. This project was maintained by the jQuery team as an official jQuery plugin. It is no longer in active development, and has been superseded by JsRender.
3.23k stars 1.01k forks source link

{{if !DATA_PROPERTY}} throws an undefined error #95

Closed jswartwood closed 13 years ago

jswartwood commented 13 years ago
{{if !DATA_PROPERTY}}

and

{{if DATA_PROPERTY == undefined}}

both throw an error... I wind up doing:

{{if DATA_PROPERTY}}{{else}} ... {{/if}}

which is awkward. If the top two approaches are impossible to solve, please provide a new template syntax for

{{not}} ... {{/not}}

or something similar.

BorisMoore commented 13 years ago

The right test is {{if typeof DATA_PROPERTY==="undefined"}}

In JavaScript code if (DATA_PROPERTY==undefined) will not work unless you have a variable called undefined which is undefined. :). In your context, you don't...

Closing the issue.