layouts
layouts copied to clipboard
Loosen dependency on jstransformers
Some of the JS transformers are severely outdated and due to the update mechanism (jstransformer-boilerplate
-> test-jstransformer
-> jstransformer-*
) this is probably going to keep being an issue in the future.
For example:
-
jstransformer-marked
uses[email protected]
while the latest version is4.0.7
(4 years ahead) -
jstransformer-handlebars
uses[email protected]
while the latest version is4.7.7
(6 years ahead)
Furthermore the renderAsync
method used in layouts is not guaranteed to be present on all jstransformers.
There are a few options:
- Fork & republish a selection of the most commonly used jstransformers.
- Narrow the selection of supported templating languages (eg markdown, handlebars, nunjucks, twig) by bundling adapters in metalsmith-layouts, and specifying
peerDependencies
andpeerDependenciesMeta: optional
- Keep using jstransformers, but provide an option
transformers: ['path/to/transformer.js', 'path/to/other/transformer.js
]` that will be added to the cache with the node_modules transformers, update the docs explaining how to create your own jstransformer.
In favor of option 3
I've become member of the jstransformer's org and have updated the 2 jstransformers mentioned.
I still think providing a transformers
option has several advantages:
- It has to be explicitly passed with
require('jstransformer-nunjucks')
-> explicit is better than implicit - It makes
inputformat-to-jstransformer
obsolete, which does a dictionary - key lookup of rendering engines matching an ext. 3. Instead, the transformer's inputFormat properties can be used, this allows custom matching & custom transformers - No need for caching the rendering engine
Disadvantages:
- Major semver breaking change
- Might need to do changes to in-place too to keep it consistent, and sync release between both
To be aligned with @metalsmith/in-place 5.x transform
option