Reputation: 759
I'm using Webpack's HtmlWebpackPlugin plugin to load repeated content within multiple pages, that way I can reuse the same code without having to duplicate it in multiple parts.
<%=require('../../partials/footer/contact.html?template').default%>
It turns out that in some cases it would be interesting to be able to have some custom text for this template.
Does this plugin allow passing parameters to the template, making it show in some variable what was passed?
I have a template that I use to display the top menus of the site, and with the use of variables/parameters I thought of indicating which page the user is on. Because installing PHP on the server just for that, or using JavaScript to "mark" the menu, doesn't seem quite right. So, I could load the template saying which is the active menu referring to the page.
Upvotes: 1
Views: 229
Reputation: 880
You can try other plugin html-bundler-webpack-plugin. This plugin allow to use many template engines.
Exact for your use case ..reuse the same code without having to duplicate it in multiple parts..
here is an example How to pass different data by multipage configuration.
Upvotes: 1