colbyfayock / html-webpack-partials-plugin

🛠 Easy HTML partials for Webpack without a custom index!
MIT License
68 stars 20 forks source link

Pass attr/variable to the partial in HTML #41

Closed nmapx closed 3 years ago

nmapx commented 3 years ago

Hi, first of all good job with developing the plugin! I'm wondering whether it's possible to pass a value into the partial from the HTML code like:

<thisIsAPartial variable="value">

so I could then use this value somewhere in the partial

<%= variable %> //of course it doesn't work - I should set this variable in options part of Webpack plugin settings

Cheers!

colbyfayock commented 3 years ago

hey @nmapx that wouldn't work as it stands because the partials aren't added to files in a component-like structure

you can however pass invariables form the webpack config

https://github.com/colbyfayock/html-webpack-partials-plugin/tree/master/examples/variables

nmapx commented 3 years ago

I'm aware of that but this is not what I'm looking for unfortunately. I wanted to setup a partial in 2 different versions (let's say most of the code is the same) and fill the differences with some variables. It seems I need to do it live, in the browser - DOM manipulation etc. I think such a feature is doable in Webpack but I won't waste your time asking for it 😄 There are plenty more or less ugly workarounds.