Allow _.template functions to be called with no arguments.

This change simply allows templates to be called with no arguments, for a behaviour equivalent to being called with an empty object, {}.
This commit is contained in:
Nick Stenning
2010-07-14 11:09:05 +01:00
parent 868c5c8d85
commit e81a2ec516
2 changed files with 5 additions and 1 deletions

View File

@@ -625,7 +625,7 @@
var endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g");
var fn = new Function('obj',
'var p=[],print=function(){p.push.apply(p,arguments);};' +
'with(obj){p.push(\'' +
'with(obj||{}){p.push(\'' +
str.replace(/[\r\t\n]/g, " ")
.replace(endMatch,"\t")
.split("'").join("\\'")