Comments (9)
What's the case for templateParameters
then?
from html-webpack-plugin.
I was looking for the same thing. So it seems like to access plugin options from the template I need to reference them as htmlWebpackPlugin.options
. That's quite verbose. Is there any way to define a 'variables' object in plugin options that could serve as 'root' for the template variables?
Eg. say I'm using Mustache. Using JS I'd render like this:
Mustache.render(template, {title: 'Hello', lang: 'en'}, {partial1: 'partial'});
Then I can simply use the variables like:
<h1>{{ title }}</h1> <img src="speechbubble_{{lang}}.png"/>
and so on. Is something similar possible with html-webpack-plugin?
from html-webpack-plugin.
It will pass all variables to the templates so you can define your own. E.g. longTitle
from html-webpack-plugin.
nope because of legacy reasons - but I really like the idea
from html-webpack-plugin.
The example on write your own templates shows how to pass the title
parameter to a custom template.
Please let me know if this what you were looking for :)
from html-webpack-plugin.
it works with
new HtmlWebpackPlugin({
template: '../html/index-template.html',
env: {
Prod: !prodFlag,
},
}),
and read then as htmlWebpackPlugin.options.env.Prod
But according to documentation it suppose to work with
new HtmlWebpackPlugin({
template: '../html/index-template.html',
prod: true
}),
and htmlWebpackPlugin.options.prod
from html-webpack-plugin.
@jantimon What if I need to pass custom variable (not from this list of allowed variables https://github.com/ampedandwired/html-webpack-plugin#configuration)?
from html-webpack-plugin.
@jantimon it's not working anymore or I'm doing something wrong, cause it's injecting custom variable only if I set inject: false
, but it's not what I want because in this case it's not injecting my bundles.
from html-webpack-plugin.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from html-webpack-plugin.
Related Issues (20)
- Insert just defer, not defer=defer HOT 1
- Ability to pass extra plugins to the child compilation HOT 5
- Ability to escape relative urls HOT 1
- How to bundle all of app's templates, styles and scripts into one single .js file, that can be exported as a library and attached to another HTML file and load?
- Is it possible to inject HTML code built from `.ejs` template into js while building and bundling with webpack? HOT 3
- Request sitemap.txt generation HOT 5
- Pre release libraries not working
- Don't update static link file in template.html HOT 1
- Writing Your Own Templates section does not work HOT 2
- ```[tasklist] ### My tasks - [ ] https://github.com/octo-org/octo-repo/issues/45 - [ ] Draft task ```
- Embed the script into HTML HOT 4
- Add a link rel=prefetch for a css chunks created within your wepbackPrefetch lazy loaded js chunks HOT 2
- Watch mode memory leak when saving HTML template HOT 1
- multi-page behavior illogical? HOT 1
- Memory leak in watch mode due to unique child compiler IDs HOT 1
- New version 5.6.0 introduce breaking changes to the plugin interface HOT 3
- CSS order not correct when using split chunks HOT 1
- File does not render correctly / cannot get variable from options HOT 3
- Allow plugin to run during a custom stage, or change default HOT 3
- Allow the plugin to support loaders that don't resolve to a single function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-webpack-plugin.