metalsmith / layouts

A metalsmith plugin for layouts
MIT License
116 stars 49 forks source link

allow pattern to match against meta properties as well as path #115

Closed leviwheatcroft closed 7 years ago

leviwheatcroft commented 7 years ago

Not sure what you think of this.. I wanted to use different engines depending on the layout specified within files, so this allows you to specify a pattern like:

.use(layouts({
  engine: 'handlebars',
  pattern: {
    path: '**/*.html',
    layout: /\.hbs$/
  }
}))

It still allows the current pattern: '**/*.html' style args.

ismay commented 7 years ago

I wanted to use different engines depending on the layout specified within files, so this allows you to specify a pattern like

I think this problem could also be solved with our move to jstransformers for layouts 2.0.0, where layouts'll use extensions to resolve engines.

Also, for now this could be solved by using multiple instances of layouts. I'd prefer that over adding this option, as that'll keep the complexity of this lib down (at the cost of a little more verbosity when using layouts for a use-case like this).

leviwheatcroft commented 7 years ago

I take your point re: jstransformers in layouts 2.0.0 - I just had a look to see what progress has already been made on this, is #105 the most recent (exposing render function) ?

ismay commented 7 years ago

I just had a look to see what progress has already been made on this, is #105 the most recent (exposing render function) ?

Yeah it is. A lot of the testing has been done on metalsmith-in-place though, which will hopefully translate to layouts as well.