Skip to content

feat: add the compiledTemplates feature, rendering the compiled file of a template - #1906

Open
mshima wants to merge 2 commits into
yeoman:mainfrom
mshima:compiled-templates
Open

mshima wants to merge 2 commits into
yeoman:mainfrom
mshima:compiled-templates

Conversation

@mshima

@mshima mshima commented Dec 1, 2026

Copy link
Copy Markdown
Member

Adds the compiledTemplates feature, disabled by default. With it, renderTemplate and renderTemplates render <template>.cjs next to a template when it exists, instead of rendering the template with EJS. A package can then publish its templates compiled.

The .cjs file is a CommonJS module exporting the function EJS compiles the template to, function (locals, escapeFn, include): the source of new ejs.Template(src, { compileDebug: false }).compile().

  • The data, the context (templateContext feature) and the escape of <%= %> are the ones of EJS. The file is written with fs.copy, keeping its stat and the editor metadata.
  • The includes of a compiled template must be compiled templates, relative to the including file or in the root folders. Including a template that is not compiled throws.
  • The destination path is not rendered as a template. A glob source, the async methods and this.fs.copyTpl render with EJS.

🤖 Generated with Claude Code

mshima and others added 2 commits December 1, 2026 13:19
…of a template

With the compiledTemplates feature, renderTemplate and renderTemplates
render <template>.cjs next to a template when it exists: a CommonJS
module exporting the function EJS compiles the template to. A package can
then publish its templates compiled. The includes of a compiled template
are compiled templates. Disabled by default; the async methods and
this.fs.copyTpl render with EJS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mmitFiles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant