mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Ensure _.template works with "interpolate" delimiters containing ternary operators. [closes #68]
Former-commit-id: 287df2ef5802ea6db743da5f211e480d6b0f85c9
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user