leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Support numbers as well as string. #55

Closed peter-schwier closed 12 years ago

peter-schwier commented 12 years ago

I can understand not filling in anything when the field is null. However, you should fill in something when the value is a number. Possibly when it is a boolean as well.

Currently it checks for truthy values. That excludes the values: 0, 0.0, and false. I would like to be able to render 0 in my templates without having to either (0).toString() or provide a directive as {number:{text:function(){return this.number.toString();}}}.

Please see the jsFiddle below. If you remove the directive from the render call then the values are not filled in. http://jsfiddle.net/Caementum/UtDH6/

pyykkis commented 12 years ago

Thanks for reporting. Will fix.

pyykkis commented 12 years ago

The problem was introduced by a recent refactoring. I added couple of tests to ensure it won't happen in the future.

https://github.com/leonidas/transparency/blob/master/spec/basics.spec.coffee#L205 https://github.com/leonidas/transparency/blob/master/spec/directives.spec.coffee#L205