can1357/oh-my-pi · error

The partial ${node.expression.name} could not be found

Error message

The partial ${node.expression.name} could not be found

What it means

renderPartial() resolves a partial by name from the runtime partials (`runtime.partials`) and the render-time partials map. If neither contains the name referenced by `{{> partialName}}`, it throws "The partial <name> could not be found" — Handlebars-compatible behavior.

Source

Thrown at packages/utils/src/template.ts:506

	}
	if (name === "with")
		return isConditionalTruthy(value)
			? renderNodes(node.body, childFrame(frame, value), evaluation)
			: renderNodes(node.inverse, frame, evaluation);
	const resolved = resolvePath(name, frame);
	if (Array.isArray(resolved))
		return (
			resolved.map(item => renderNodes(node.body, childFrame(frame, item), evaluation)).join("") ||
			renderNodes(node.inverse, frame, evaluation)
		);
	return resolved === false || resolved == null
		? renderNodes(node.inverse, frame, evaluation)
		: renderNodes(node.body, childFrame(frame, resolved), evaluation);
}

function renderPartial(node: PartialNode, frame: Frame, evaluation: Evaluation): string {
	const partial = evaluation.runtime.partials?.[node.expression.name] ?? evaluation.partials.get(node.expression.name);
	if (partial === undefined) throw new Error(`The partial ${node.expression.name} could not be found`);
	const context = node.expression.args.length
		? evaluateExpression(node.expression.args[0], frame, evaluation)
		: frame.context;
	const hash = evaluateHash(node.expression.hash, frame, evaluation);
	const merged =
		hash && context && typeof context === "object" ? { ...(context as Record<string, unknown>), ...hash } : context;
	return typeof partial === "function"
		? partial(merged, evaluation.runtime)
		: compile(partial, evaluation.options)(merged, evaluation.runtime);
}

function stringify(value: unknown, shouldEscape: boolean): string {
	if (value == null) return "";
	if (value instanceof SafeString) return value.toString();
	const text = String(value);
	return shouldEscape ? escapeExpression(text) : text;
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass the partial in the render options: `{ partials: { header: '<header>...</header>' } }`.
  2. Fix the template to reference the correct partial name (check casing — the lookup is exact).
  3. If partials are loaded from a directory, ensure the loader registers all files before rendering.

Example fix

// before
render('{{> header}}', data);
// after
render('{{> header}}', data, { partials: { header: '<h1>{{title}}</h1>' } });
Defensive patterns

Strategy: validation

Validate before calling

function assertPartialsAvailable(src, partials = {}, runtimePartials = {}) {
  const names = new Set();
  for (const t of src.match(/\{\{>\s*[^}\s]+/g) ?? []) {
    names.add(t.replace(/^\{\{>\s*/, ''));
  }
  const missing = [...names].filter(n => !(n in partials) && !(n in runtimePartials));
  if (missing.length) throw new Error(`Missing partials referenced by template: ${missing.join(', ')}`);
}

Try / catch

try {
  return render(src, data, { partials });
} catch (err) {
  const m = /^The partial (.+) could not be found$/.exec(err?.message ?? '');
  if (m) throw new Error(`Register partial "${m[1]}" in the partials option before rendering`);
  throw err;
}

Prevention

When it happens

Trigger: Rendering a template with `{{> header}}` (or `{{>header ctx}}`) where `header` was not supplied via the partials option/map used for this render.

Common situations: Templates referencing project partials while rendering through an entry point that doesn't load the partials directory; a rename of the partial file without updating `{{> ...}}` references; per-render partials maps that only include some partials; nesting partials that reference siblings not passed down.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/2630747306bd7852. Report an issue: GitHub.