interpolate-html-plugin
interpolate-html-plugin copied to clipboard
Support for nested objects
Can I submit a PR to allow for an object of objects to be passed to the interpolate plugin?
This would allow me to do
const config = {
'foo': 'bar',
'bar': {
'foofoo': 'barbar'
}
}
And then in my .html file
<link href="//%bar.foofoo%/assets/css.css" rel="stylesheet" type="text/css"></link>
Maybe we can just make it support custom template engine?
For your use case you can just pass that config as html-webpack-plugin's options:
new HtmlWebpackPlugin({
config
})
How do you mean?
When I pass in nested objects aka config above I can't access those properties by doing bar.foofoo in the HTML template. Could you elebarote a bit more about how that would work please?
I mean this plugin is totally unnecessary, you can directly access the options of html-webpack-plugin instance in your template:
// webpack config
new HtmlWebpackPlugin({
config,
template: './some/index.template.html'
})
Then in your template index.template.html:
// html-webpack-plugin uses ejs template syntax by default
<%= htmlWebpackPlugin.options.config.foo.bar %>
Oh I didn't know that was possible. Thanks for that @egoist