mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Make compiled templates more debuggable.
Former-commit-id: aba1aa3efcea6695632aae0eb61148aa3174debd
This commit is contained in:
@@ -3421,7 +3421,11 @@
|
|||||||
text += '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']';
|
text += '\n//@ sourceURL=/lodash/template/source[' + (templateCounter++) + ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Function('_', 'return ' + text)(lodash);
|
try {
|
||||||
|
result = Function('_', 'return ' + text)(lodash);
|
||||||
|
} catch(e) {
|
||||||
|
result = function() { throw e; };
|
||||||
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
return result(data);
|
return result(data);
|
||||||
|
|||||||
@@ -734,6 +734,15 @@
|
|||||||
deepEqual(options, {});
|
deepEqual(options, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should be debuggable if compiled with errors', function() {
|
||||||
|
var source = _.template('<% if x %>').source;
|
||||||
|
ok(source.indexOf('__p') > -1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should raise an error if a template, compiled with errors, is executed', function() {
|
||||||
|
raises(_.template('<% if x %>'));
|
||||||
|
});
|
||||||
|
|
||||||
test('should work with complex "interpolate" delimiters', function() {
|
test('should work with complex "interpolate" delimiters', function() {
|
||||||
_.each({
|
_.each({
|
||||||
'<%= a + b %>': '3',
|
'<%= a + b %>': '3',
|
||||||
|
|||||||
Reference in New Issue
Block a user