Add support for dynamic partial names
Uses the subexpression syntax to allow for dynamic partial lookups. Ex:
```
{{> (helper) }}
```
Fixes #933
This commit is contained in:
@@ -644,17 +644,26 @@ JavaScriptCompiler.prototype = {
|
||||
//
|
||||
// This operation pops off a context, invokes a partial with that context,
|
||||
// and pushes the result of the invocation back.
|
||||
invokePartial: function(name, indent) {
|
||||
invokePartial: function(isDynamic, name, indent) {
|
||||
var params = [],
|
||||
options = this.setupParams(name, 1, params, false);
|
||||
|
||||
if (isDynamic) {
|
||||
name = this.popStack();
|
||||
delete options.name;
|
||||
}
|
||||
|
||||
if (indent) {
|
||||
options.indent = JSON.stringify(indent);
|
||||
}
|
||||
options.helpers = 'helpers';
|
||||
options.partials = 'partials';
|
||||
|
||||
params.unshift(this.nameLookup('partials', name, 'partial'));
|
||||
if (!isDynamic) {
|
||||
params.unshift(this.nameLookup('partials', name, 'partial'));
|
||||
} else {
|
||||
params.unshift(name);
|
||||
}
|
||||
|
||||
if (this.options.compat) {
|
||||
options.depths = 'depths';
|
||||
|
||||
Reference in New Issue
Block a user