diff --git a/.gitignore b/.gitignore index a4c0df6..9dcf445 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dojox yui3 qooxdoo.mustache.js +npm-debug.log diff --git a/mustache.js b/mustache.js index 47a396d..825b0c9 100644 --- a/mustache.js +++ b/mustache.js @@ -481,7 +481,7 @@ for (var j = 0, valueLength = value.length; j < valueLength; ++j) { buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate); } - } else if (typeof value === 'object' || typeof value === 'string') { + } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') { buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate); } else if (isFunction(value)) { if (typeof originalTemplate !== 'string') diff --git a/test/_files/implicit_iterator.js b/test/_files/implicit_iterator.js new file mode 100644 index 0000000..2be2997 --- /dev/null +++ b/test/_files/implicit_iterator.js @@ -0,0 +1,8 @@ +({ + data: { + author: { + twitter_id: 819606, + name: 'janl' + } + } +}) diff --git a/test/_files/implicit_iterator.mustache b/test/_files/implicit_iterator.mustache new file mode 100644 index 0000000..ae31f34 --- /dev/null +++ b/test/_files/implicit_iterator.mustache @@ -0,0 +1,7 @@ +{{# data.author.twitter_id }} + +{{/ data.author.twitter_id }} + +{{# data.author.name }} + +{{/ data.author.name }} diff --git a/test/_files/implicit_iterator.txt b/test/_files/implicit_iterator.txt new file mode 100644 index 0000000..0fccefd --- /dev/null +++ b/test/_files/implicit_iterator.txt @@ -0,0 +1,3 @@ + + + diff --git a/test/render-test.js b/test/render-test.js index a011678..6aec0cf 100644 --- a/test/render-test.js +++ b/test/render-test.js @@ -5,7 +5,11 @@ var path = require('path'); var _files = path.join(__dirname, '_files'); function getContents(testName, ext) { - return fs.readFileSync(path.join(_files, testName + '.' + ext), 'utf8'); + try { + return fs.readFileSync(path.join(_files, testName + '.' + ext), 'utf8'); + } catch (ex) { + return null; + } } function getView(testName) {