handlebars-lang/handlebars.js · error · Exception
Unsupported number of partial arguments: ${params.length}
Error message
Unsupported number of partial arguments: ${params.length} What it means
Thrown by the compiler's PartialStatement handler when a partial invocation supplies more than one parameter (e.g. {{> partial a b}}). Handlebars partials accept at most one additional argument, which becomes the partial's context, so any extra positional parameters make the template uncompilable. Fix the template to pass only the partial plus an optional single context argument, or move extra values into the context/hash instead.
Source
Thrown at lib/handlebars/compiler/compiler.js:171
let program = decorator.program && this.compileProgram(decorator.program);
let params = this.setupFullMustacheParams(decorator, program, undefined),
path = decorator.path;
this.useDecorators = true;
this.opcode('registerDecorator', params.length, path.original);
},
PartialStatement: function (partial) {
this.usePartial = true;
let program = partial.program;
if (program) {
program = this.compileProgram(partial.program);
}
let params = partial.params;
if (params.length > 1) {
throw new Exception(
'Unsupported number of partial arguments: ' + params.length,
partial
);
} else if (!params.length) {
if (this.options.explicitPartialContext) {
this.opcode('pushLiteral', 'undefined');
} else {
params.push({ type: 'PathExpression', parts: [], depth: 0 });
}
}
let partialName = partial.name.original,
isDynamic = partial.name.type === 'SubExpression';
if (isDynamic) {
this.accept(partial.name);
}
this.setupFullMustacheParams(partial, program, undefined, true);View on GitHub (pinned to 13a7a67991)
Solutions
- Reduce to at most one argument: {{> myPartial arg}} or {{> myPartial contextHash=a b=c}} (hash is fine).
- Combine multiple values into a single object literal or hash arguments.
- Use a helper instead of a partial if you need multiple positional arguments.
Example fix
// before
{{> userCard firstName lastName}}
// after
{{> userCard user}} Defensive patterns
Strategy: validation
Validate before calling
// lint templates before compile: partial invocations must have <= 1 param
function validatePartialArgs(templateSrc) {
const ast = Handlebars.parse(templateSrc);
const bad = [];
(function walk(n) {
if (!n || typeof n !== 'object') return;
if (n.type === 'PartialStatement' && n.params.length > 1) bad.push(n.name && n.name.original);
Object.values(n).forEach(walk);
})(ast);
return bad;
} Try / catch
try { Handlebars.compile(src); } catch (e) { if (/Unsupported number of partial arguments/.test(e.message)) { /* fix template: reduce to one arg */ } throw e; } Prevention
- Remember partials take at most one positional argument; use hash args for more data.
- Lint templates in CI using Handlebars.parse before shipping.
- Use helpers instead of partials when multiple arguments are needed.
When it happens
Trigger: Templates like {{> myPartial arg1 arg2}} compile — params.length > 1 in MustachePartialStatement/partialBlock.
Common situations: Authoring templates assuming partials behave like helper calls with arbitrary arguments; migrating helpers to partials without dropping extra args.
Related errors
- Attempting to register a partial called "${name}" as undefin
- The partial ${options.name} could not be compiled when runni
- The partial "${options.name}" could not be found
AI-assisted analysis of handlebars-lang/handlebars.js@13a7a67991 (2026-09-02).
Data as JSON: /api/errors/94f7da5007fd729f.
Report an issue: GitHub.