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

Support for nested objects #4

Open
elliottcrush opened this issue Nov 20, 2017 · 4 comments
Open

Support for nested objects #4

elliottcrush opened this issue Nov 20, 2017 · 4 comments

Comments

@elliottcrush
Copy link

elliottcrush commented Nov 20, 2017

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>

@egoist
Copy link
Owner

egoist commented Nov 20, 2017

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
})

@elliottcrush
Copy link
Author

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?

@egoist
Copy link
Owner

egoist commented Nov 20, 2017

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 %>

@elliottcrush
Copy link
Author

Oh I didn't know that was possible. Thanks for that @egoist

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