mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Fix template regressions. [Closes #44]
Former-commit-id: 15e98d86c290fea74780822b49b5d71e54064e01
This commit is contained in:
25
test/test.js
25
test/test.js
@@ -771,9 +771,32 @@
|
||||
var compiled = _.template(key),
|
||||
data = { 'a': 1, 'b': 2 };
|
||||
|
||||
equal(compiled(data), value);
|
||||
equal(compiled(data), value, key);
|
||||
});
|
||||
});
|
||||
|
||||
test('should allow referencing variables declared in "evaluate" delimiters from other delimiters', function() {
|
||||
var compiled = _.template('<% var b = a; %><%= b.value %>'),
|
||||
data = { 'a': { 'value': 1 } };
|
||||
|
||||
equal(compiled(data), '1');
|
||||
});
|
||||
|
||||
test('should work when passing `options.variable`', function() {
|
||||
var compiled = _.template(
|
||||
'<% _.forEach( data.a, function( value ) { %>' +
|
||||
'<%= value.valueOf() %>' +
|
||||
'<% }) %>', null, { 'variable': 'data' }
|
||||
);
|
||||
|
||||
var data = { 'a': [1, 2, 3] };
|
||||
|
||||
try {
|
||||
equal(compiled(data), '123');
|
||||
} catch(e) {
|
||||
ok(false);
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user