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

Bug with passing parameter {{tmpl}} #64

Closed i-sinister closed 13 years ago

i-sinister commented 13 years ago

When trying to pass boolean value "false" to tmpl current object is passed instead. Example:

<script id="tmplObjectView" type="text/x-jquery-tmpl">${IntProp} : {{tmpl(BoolProp) "#tmplBoolean2"}}</script>

Variable a will be "1 : yes"

i-sinister commented 13 years ago

As a workaround I wrap boolean values with an object: {{tmpl({value: BoolProp}) "#tmplBoolean2"}} and use {{ if $data.value.... in template

BorisMoore commented 13 years ago

No, you are correct, it should treat 'false' as data, and similarly if you pass 0 as data. OTOH if you call tmpl() with no parameter (undefined), then it should render the template once, with an empty object as data. Passing null should still be treated as passing with no parameter...

Thanks...

BorisMoore commented 13 years ago

Fixed in https://github.com/jquery/jquery-tmpl/commit/60024579d2b6ca54d4c9ecfd5357f9d09aa7b10b.