Pug include partial local inheritance and include path resolution
0 reputation · 12 May 2025, 16:51 UTC
Pug include partial local inheritance and include path resolution
A parent Pug template is rendered with pug.renderFile and includes a partial at compile time. The parent passes a locals object containing several variables, and the partial references one of them. The goal is to determine whether the included partial inherits the complete locals object from the including template or only a limited subset, and whether a relative include path resolves against the filename directory, the basedir option, or both.
Assumptions: Pug v3 is installed. Include directives are resolved at compile time, so the partial path cannot be a runtime variable. Mixins are excluded because they create an isolated parameter scope. Version-specific defaults for filename and basedir interaction are not assumed.
Questions:
- Does an included partial receive the full locals object of the parent template in Pug v3?
- When both filename and basedir are provided, which root governs relative include path resolution?