Permalink
Browse files

Undefined + null + 0 + false

  • Loading branch information...
turigabor committed Dec 3, 2013
1 parent c3add85 commit 1a9ea646dc072315b38c20044795c40cd91786a4
Showing with 16 additions and 1 deletion.
  1. +4 −1 template.js
  2. +12 −0 tests/template_test.js
View
@@ -51,7 +51,10 @@ JSTemplate.prototype = {
},
/** @private */
getValueByName: function (name) {
return this.values[name] || '';
if (typeof this.values[name] === 'undefined' || this.values[name] === null) {
return '';
}
return this.values[name];
},
/** @private */
createFilterParams: function (value, param) {
View
@@ -94,6 +94,18 @@ describe('simple', function () {
t.append(obj);
expect(t.fetch()).toEqual(result);
});
it('Undefined + null + 0 + false', function () {
var str = '{$undef}-{$null}-{$zero}-{$false}',
obj = {
'null': null,
'zero': 0,
'false': 'false'
},
result = '--0-false',
t = new JSTemplate(str);
t.append(obj);
expect(t.fetch()).toEqual(result);
});
});
describe('filters', function () {

0 comments on commit 1a9ea64

Please sign in to comment.