Skip to content

Allow template engine overrides with addExtension, with access to the "default" engine#1871

Merged
zachleat merged 6 commits into
11ty:masterfrom
bholmesdev:feat/add-extension-override-default-engines
Aug 15, 2021
Merged

Allow template engine overrides with addExtension, with access to the "default" engine#1871
zachleat merged 6 commits into
11ty:masterfrom
bholmesdev:feat/add-extension-override-default-engines

Conversation

@ghost

@ghost ghost commented Jul 1, 2021

Copy link
Copy Markdown

Resolves #1870
☝️ Full description of this change over there!

Comment thread src/TemplateEngineManager.js Outdated
Comment thread src/TemplateEngineManager.js

@zachleat zachleat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the tidyness of this PR! Very easily reviewable. Just a few very small points!

Comment thread src/Engines/Custom.js
}

async compile(str, inputPath) {
async compile(str, inputPath, ...args) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is args used for here? Future compatibility? or are you relying on it somewhere else

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zachleat Looks like this is necessary actually! The issue is with the defaultRenderer that's getting defined a few lines down.

For instance, the Markdown engine takes in 4 parameters for compile:

compile(str, inputPath, preTemplateEngine, bypassMarkdown)

So if your Custom engine is overriding markdown, it'll need to pass these extra args (preTemplateEngine, bypassMarkdown) to the markdown engine. ...args was just a quick way to grab those extra properties. Hope that makes sense!

Comment thread src/TemplateEngineManager.js
Comment thread src/TemplateEngineManager.js Outdated
@zachleat zachleat added this to the Eleventy 1.0.0 milestone Aug 10, 2021
@ghost ghost force-pushed the feat/add-extension-override-default-engines branch from bb3f02e to ec9b3f1 Compare August 15, 2021 00:32
@ghost ghost force-pushed the feat/add-extension-override-default-engines branch from ec9b3f1 to c4c5455 Compare August 15, 2021 00:42
@zachleat zachleat merged commit 6776e87 into 11ty:master Aug 15, 2021
@zachleat

Copy link
Copy Markdown
Member

This will ship with Canary 42, thanks!

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

Development

Successfully merging this pull request may close these issues.

Allow template engine overrides with addExtension, with access to the "default" engine

2 participants