kalamuna / metalsmith-jstransformer

Metalsmith JSTransformers Plugin
http://npm.im/metalsmith-jstransformer
MIT License
7 stars 9 forks source link

Add .engineOptions and .engineLocals #16

Closed RobLoach closed 7 years ago

RobLoach commented 7 years ago

This fixes #3....

Should this be named engineOptions and engineLocals or something else? transformerOptions and transformerLocals instead?

@Zearin @calebeby @thiagodemellobueno Thoughts?

thiagodemellobueno commented 7 years ago

I vote for engineOptions, assuming its specific to template engines. If its general options for any transformer, then I can see transformerOptions being a thing.

I would not say locals.

Can you provide a small idealized example? Eg, what do you touch? Is it a config file? or front matter? Per file? or for any given engine (much much preferred)

I would argue against front matter implementations since it provides non-valid non parseable-by-other-tools markup in some cases (sass)

RobLoach commented 7 years ago

Added two examples in the docs........

.engineOptions

engineOptions: {
  // Add our own SASS include paths.
  scss: {
    includePaths: [
      'styles/mystyles',
      'node_modules/bootstrap'
    ]
  }
}

.engineLocals

Allows passing in local variables for the given engines.

engineLocals: {
  // All Twig templates will have the `baseURL` local variable.
  twig: {
    baseURL: 'http://mywebsite.com/'
  }
}
RobLoach commented 7 years ago

Let's roll with this for now, we can rename it later on, if needed.