totaljs / Tangular

A simple JavaScript template engine like Angular.js for websites or node.js
MIT License
61 stars 21 forks source link

Fix the property of undefined object #7

Closed webarthur closed 8 years ago

webarthur commented 8 years ago

My case:

Script stop if try to compile "object.length" when object=undefined. Fixed with try/catch.

petersirka commented 8 years ago

Thanks!

petersirka commented 8 years ago

@webarthur I tested it and your update doesn't work. I reverted the commit.

Solution for you:

{{ if object }}
<div>{{ object.length }}</div>
{{ fi }}

Thanks!

webarthur commented 8 years ago

Mustache and AngularJS don't have this trouble. Use an IF for each empty object is not a good solution. I'm working in a small mvvm jquery framework, but ok... Thank you too!