mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +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._;
|
var oldDash = window._;
|
||||||
|
|
||||||
/** Used to detect delimiter values that should be processed by `tokenizeEvaluate` */
|
/** 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 */
|
/** Used to match HTML entities */
|
||||||
var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g;
|
var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g;
|
||||||
|
|||||||
@@ -1499,6 +1499,11 @@
|
|||||||
var compiled = _.template('<span class="icon-<%= type %>2"></span>');
|
var compiled = _.template('<span class="icon-<%= type %>2"></span>');
|
||||||
equal(compiled({ 'type': 1 }), '<span class="icon-12"></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