Преглед изворни кода

Fail gracefully on empty template

Fixes #267
tags/0.7.1
Michael Jackson пре 13 година
родитељ
комит
e0edb356ae
2 измењених фајлова са 3 додато и 1 уклоњено
  1. +2
    -1
      mustache.js
  2. +1
    -0
      test/parse_test.js

+ 2
- 1
mustache.js Прегледај датотеку

@@ -443,7 +443,7 @@ var Mustache;
}
}

return squashedTokens;
return squashedTokens;
}

function escapeTags(tags) {
@@ -464,6 +464,7 @@ var Mustache;
* course, the default is to use mustaches (i.e. Mustache.tags).
*/
exports.parse = function (template, tags) {
template = template || '';
tags = tags || exports.tags;

var tagRes = escapeTags(tags);


+ 1
- 0
test/parse_test.js Прегледај датотеку

@@ -5,6 +5,7 @@ var Mustache = require('./../mustache');
// A map of templates to their expected token output. Tokens are in the format:
// [type, value, startIndex, endIndex].
var expectations = {
'' : [],
'{{hi}}' : [ [ 'name', 'hi', 0, 6 ] ],
'{{hi.world}}' : [ [ 'name', 'hi.world', 0, 12 ] ],
'{{hi . world}}' : [ [ 'name', 'hi . world', 0, 14 ] ],


Loading…
Откажи
Сачувај