Closed ismay closed 5 years ago
Also came across this limitation. 👍
@RobLoach I guess it depends on the underlying library where the filename property is expected to be (if the transformer needs it, and some call it path
)? As in, either in locals or engineOptions?
Because I could of course manually add it, but since the goal of jstransformers is to standardize the api of all these transforms, maybe it'd be good to come up with something that works similarly across all jstransformers.
It should be passed in options
not locals
. The locals
are for variables local to the current render. options
are for the current file. A template gets compiled once with a set of options
and can then be rendered multiple times with different locals
. This is for building dynamic applications, so that the template can be compiled only once.
In metalsmith-in-place I'm using jstransformer's
.render
to render templates (here). As I understand it, that means that for pug this'll use thecompile
export. But the exported compile from this lib only accepts asource
andoptions
param. Whereas in the.render
docs it refers to acceptingstring
,options
andlocals
.In locals I'm passing an object with a filename property, but since that parameter isn't used, compiling with pug fails. To me it makes sense to pass this in locals though (as it's info related to the file being processing, and not a general engine setting). Would it be possible to address this issue?
See: https://github.com/metalsmith/metalsmith-in-place/issues/158