kalamuna / metalsmith-jstransformer-partials

Metalsmith JSTransformer Partials Plugin
http://npm.im/metalsmith-jstransformer-partials
MIT License
1 stars 1 forks source link

Add support for multiple transforms on partials #4

Open wilsonminer opened 8 years ago

wilsonminer commented 8 years ago

Not sure if this should be supported, but wanted to ask in case there's a way around it that I'm missing.

If I have a markdown file that I want to process for Handlebars partials before converting to HTML, I can apply both transforms by adding both extensions (foo.md.hbs). This works great.

If I include the same file as a partial itself (using partial: true in the front-matter, the multiple extensions don't work (the build fails) and if I just name the file foo.md the partials don't get parsed before the markdown conversion.

Would it make sense to support multiple extensions on partials themselves, or is there another way to apply multiple transforms on partials when they are processed for inclusion?

RobLoach commented 8 years ago

That's a great idea, @wilsonminer. It's not in currently, but would be a great addition!

At the compileAync part, you'll see it compiles each partial, and then caches the function that's returned. This means for JSTransformers that can compile their templates, partials end up being quite fast. With multiple transforms, I'm unsure we could compile them ontop of each other. Probably a solution around it would be to add the iterative transformer.render() calls in executePartial(), after the first .apply call.

Thoughts?