Closed cossssmin closed 3 years ago
This PR adds support for passing locals inside the options object, as described in #56
Besides the locals='' attribute, we can now also pass data to a module through a locals object in the plugin options:
locals=''
locals
posthtml() .use(require('posthtml-modules')({ locals: {} // custom data object })) .process(readFileSync('index.html', 'utf8')) .then(result => result) })
Note: lodash was added as a dependency so that we can safely deep merge the locals from options with the ones from the locals="" attribute. Uses destructuring, so we don't load the entire library unnecessarily.
lodash
options
locals=""
If merged, closes #56
@cossssmin publish v0.7.0
This PR adds support for passing locals inside the options object, as described in #56
Besides the
locals=''
attribute, we can now also pass data to a module through alocals
object in the plugin options:Note:
lodash
was added as a dependency so that we can safely deep merge the locals fromoptions
with the ones from thelocals=""
attribute. Uses destructuring, so we don't load the entire library unnecessarily.If merged, closes #56