Bläddra i källkod

Fail gracefully on empty template

Fixes #267
tags/0.7.1
Michael Jackson 13 år sedan
förälder
incheckning
e0edb356ae
2 ändrade filer med 3 tillägg och 1 borttagningar
  1. +2
    -1
      mustache.js
  2. +1
    -0
      test/parse_test.js

+ 2
- 1
mustache.js Visa fil

@@ -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 Visa fil

@@ -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 ] ],


Laddar…
Avbryt
Spara