Skip to content
Permalink
Browse files
Undefined + null + 0 + false
  • Loading branch information
turigabor committed Dec 3, 2013
1 parent c3add85 commit 1a9ea646dc072315b38c20044795c40cd91786a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
@@ -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) {
@@ -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.