Ensure _.template works with "interpolate" delimiters containing ternary operators. [closes #68]

Former-commit-id: 287df2ef5802ea6db743da5f211e480d6b0f85c9
This commit is contained in:
John-David Dalton
2012-09-07 21:17:00 -07:00
parent 958ac72805
commit 2dc53223e5
2 changed files with 6 additions and 1 deletions

View File

@@ -54,7 +54,7 @@
var oldDash = window._;
/** Used to detect delimiter values that should be processed by `tokenizeEvaluate` */
var reComplexDelimiter = /[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/;
var reComplexDelimiter = /[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/;
/** Used to match HTML entities */
var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g;

View File

@@ -1499,6 +1499,11 @@
var compiled = _.template('<span class="icon-<%= type %>2"></span>');
equal(compiled({ 'type': 1 }), '<span class="icon-12"></span>');
});
test('should work with "interpolate" delimiters containing ternary operators', function() {
var compiled = _.template('<%= value ? value : "b" %>');
equal(compiled({ 'value': 'a' }), 'a');
});
}());
/*--------------------------------------------------------------------------*/