@@ -177,7 +177,11 @@ Compiler.prototype = {
|
||||
if (params.length > 1) {
|
||||
throw new Exception('Unsupported number of partial arguments: ' + params.length, partial);
|
||||
} else if (!params.length) {
|
||||
params.push({type: 'PathExpression', parts: [], depth: 0});
|
||||
if (this.options.explicitPartialContext) {
|
||||
this.opcode('pushLiteral', 'undefined');
|
||||
} else {
|
||||
params.push({type: 'PathExpression', parts: [], depth: 0});
|
||||
}
|
||||
}
|
||||
|
||||
let partialName = partial.name.original,
|
||||
|
||||
@@ -41,6 +41,21 @@ describe('partials', function() {
|
||||
'Partials can be passed a context');
|
||||
});
|
||||
|
||||
it('partials with no context', function() {
|
||||
var partial = '{{name}} ({{url}}) ';
|
||||
var hash = {dudes: [{name: 'Yehuda', url: 'http://yehuda'}, {name: 'Alan', url: 'http://alan'}]};
|
||||
shouldCompileToWithPartials(
|
||||
'Dudes: {{#dudes}}{{>dude}}{{/dudes}}',
|
||||
[hash, {}, {dude: partial}, {explicitPartialContext: true}],
|
||||
true,
|
||||
'Dudes: () () ');
|
||||
shouldCompileToWithPartials(
|
||||
'Dudes: {{#dudes}}{{>dude name="foo"}}{{/dudes}}',
|
||||
[hash, {}, {dude: partial}, {explicitPartialContext: true}],
|
||||
true,
|
||||
'Dudes: foo () foo () ');
|
||||
});
|
||||
|
||||
it('partials with string context', function() {
|
||||
var string = 'Dudes: {{>dude "dudes"}}';
|
||||
var partial = '{{.}}';
|
||||
|
||||
Reference in New Issue
Block a user