Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layouts and in-place #9

Open
ismay opened this issue Jun 10, 2016 · 2 comments
Open

layouts and in-place #9

ismay opened this issue Jun 10, 2016 · 2 comments

Comments

@ismay
Copy link

ismay commented Jun 10, 2016

For metalsmith layouts and in-place we've been thinking about switching to jstransformer as our rendering engine: metalsmith/layouts#100. I personally like the modular approach and think it would be an improvement over consolidate. However, since this lib already exists it would maybe be a bit of a duplication of functionality.

We could switch to jstransformer for layouts and in-place and add you as a maintainer there, if you'd be open to that of course. Or maybe both libs have their own unique niche and it would make sense to develop them separately? What do you think?

@RobLoach
Copy link
Contributor

Hi @ismay, thanks for reaching out. Glad you made an issue about this, not only about considering metalsmith-jstransformer, but also about switching to jstransformers.

Design Changes

There are a few design considerations between how metalsmith-jstransformer and metalsmith-layouts/metalsmith-in-place operate:

  1. metalsmith-jstransformer does both the in-place rendering, and layouts
  2. metalsmith-jstransformer-partials is split into its own project
  3. metalsmith-jstransformer renames all the files it processes on to what the acting JSTransformer outputs (i.e. uglify-js will output .js, while handlebars will output .html)
  4. There is currently no metalsmith-in-place.opts.pattern equivalent. metalsmith-jstransformer just processes on all files. Made an issue for that: Add "pattern" option #10
  5. The layouts in metalsmith-jstransformer operate in the src/layouts directory, as opposed to a directory outside Metalsmith source path
  6. metalsmith-jstransformer allows running multiple JSTranformers on one file (ie main.js.uglify-js.babel)

Moving Forwards

Taking these into consideration, I see a few options going forwards and would love your ideas too:

  1. Simply replace Consolidate.js with JSTransformer in metalsmith-in-place@2.x and metalsmith-layouts@2.x
    • Easiest way would be to use consolidate-jstransformer and inform people to add the JSTranformer engines to their project with npm i jstransformer-handlebars --save
    • You'd be missing out on some of the additional features this project provides
  2. Make metalsmith-in-place@2.x and metalsmith-layouts@2.x use metalsmith-jstransformer
    • Adapt the options and push them over to metalsmith-jstransformer, affectively inheriting the plugin
  3. Add an install notice to metalsmith-in-place informing people to switch over to metalsmith-jstransformer
    • Similar to how metalsmith-templates moved over to metalsmith-in-place/metalsmith-layouts

I think taking option 1 for now is the easiest way forwards, at least for now. I'd love your thoughts! Where do you think we could go with this?

@ismay
Copy link
Author

ismay commented Jun 26, 2016

Apologies for the late reply. I think a variation of option 2 makes the most sense to me.

But instead of inheriting metalsmith-jstransformer I prefer implementing the jstransformer lib directly. That way we're just switching the engine that does the rendering and not depending on a different metalsmith plugin (in which case I'd say it would be better for people to just use that plugin directly).

I think it would be good to reconsider the layouts and in-place api, and see what we want to keep and what not. The separation between layouts and in-place is also something worth revisiting, but there'd have to be convincing arguments for merging them back together as the separation was the entire point of creating both those libs to begin with :).

So lots of work to be done :). Thanks for your feedback!

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

No branches or pull requests

2 participants