Просмотр исходного кода

Fail gracefully on empty template

Fixes #267
tags/0.7.1
Michael Jackson 13 лет назад
Родитель
Сommit
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) { function escapeTags(tags) {
@@ -464,6 +464,7 @@ var Mustache;
* course, the default is to use mustaches (i.e. Mustache.tags). * course, the default is to use mustaches (i.e. Mustache.tags).
*/ */
exports.parse = function (template, tags) { exports.parse = function (template, tags) {
template = template || '';
tags = tags || exports.tags; tags = tags || exports.tags;


var tagRes = escapeTags(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: // A map of templates to their expected token output. Tokens are in the format:
// [type, value, startIndex, endIndex]. // [type, value, startIndex, endIndex].
var expectations = { var expectations = {
'' : [],
'{{hi}}' : [ [ 'name', 'hi', 0, 6 ] ], '{{hi}}' : [ [ 'name', 'hi', 0, 6 ] ],
'{{hi.world}}' : [ [ 'name', 'hi.world', 0, 12 ] ], '{{hi.world}}' : [ [ 'name', 'hi.world', 0, 12 ] ],
'{{hi . world}}' : [ [ 'name', 'hi . world', 0, 14 ] ], '{{hi . world}}' : [ [ 'name', 'hi . world', 0, 14 ] ],


Загрузка…
Отмена
Сохранить