You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -144,8 +144,8 @@ Allowed values are as follows
144
144
|**`title`**|`{String}`|`Webpack App`|The title to use for the generated HTML document|
145
145
|**`filename`**|`{String}`|`'index.html'`|The file to write the HTML to. Defaults to `index.html`. You can specify a subdirectory here too (eg: `assets/admin.html`)|
146
146
|**`template`**|`{String}`|``|`webpack` relative or absolute path to the template. By default it will use `src/index.ejs` if it exists. Please see the [docs](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md) for details|
147
-
|**`templateParameters`**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template |
148
-
|**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `true` or `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element|
147
+
|**`templateParameters`**|`{Boolean\|Object\|Function}`|``| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters)|
148
+
|**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `true` or `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)|
149
149
|**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML|
150
150
|**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
151
151
|**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`|
This example shows how you can define the position where the scripts are injected
4
+
by setting `inject:false` and using the template parameters inside the `inside.ejs`
5
+
6
+
The example is using the template parameters `headTags` and `bodyTags`
7
+
8
+
```
9
+
<%= htmlWebpackPlugin.tags.headTags %>
10
+
<%= htmlWebpackPlugin.tags.bodyTags %>
11
+
```
12
+
13
+
`headTags` and `bodyTags` are arrays so you can use any Array.prototype function like `filter`:
14
+
15
+
```
16
+
<%= htmlWebpackPlugin
17
+
.tags
18
+
.headTags
19
+
.filter((tag) => tag.tagName === 'meta')
20
+
.join('')
21
+
%>
22
+
```
23
+
24
+
For further information about the tag object take a look at the `createHtmlTagObject` inside `lib/html-tags.js` or at the `prepareAssetTagGroupForRendering` inside `index.js`.
<head><linkhref="styles.css" rel="stylesheet"></head>Hello World from backend2019-04-25T12:53:42.170Z<h2>Partial</h2><imgsrc="0714810ae3fb211173e2964249507195.png"><scriptsrc="bundle.js"></script>
1
+
<head><linkhref="styles.css" rel="stylesheet"></head>Hello World from backend2019-07-22T06:55:15.576Z<h2>Partial</h2><imgsrc="0714810ae3fb211173e2964249507195.png"><scriptsrc="bundle.js"></script>
@jantimon the ability to call toString on the individual tag-objects would be very useful for me in my current object, but it seems that this is not yet released as part of the latest beta. Any chance to get a new beta with this feature included? Thanks!
1 commit comments
aKzenT commentedon Sep 4, 2019
@jantimon the ability to call toString on the individual tag-objects would be very useful for me in my current object, but it seems that this is not yet released as part of the latest beta. Any chance to get a new beta with this feature included? Thanks!