Explicit documentation about sub-templating

Maybe I should split this PR into 2 commits, you will tell me

* there was one comma `;` in the example that made my build crash.
* judging by the hard time people have when using this feature, including myself, there is clearly some miss-understanding #230 #202 #198 #176
This commit is contained in:
Jérôme Steunou 2016-02-19 10:54:27 +01:00
parent 713643f84f
commit 19f0eeb0d2
1 changed files with 19 additions and 2 deletions

View File

@ -72,13 +72,30 @@ This also removes the `o` in template variables. ` <body class="{%= o.htmlWebpac
# Loaders in templates
Loaders may now be used inside the template the same way as you would expect in your javascript files.
For the following example you would have to configure a html and url/file-loader:
```html
<link rel="apple-touch-icon" href="<%- require('../images/favicons/apple-icon-60x60.png') %>">
<%= require('partial.html'); %>
<%= require('partial.html') %>
```
For the above example you would have to configure a [html](https://github.com/webpack/html-loader) and url/[file-loader](https://github.com/webpack/file-loader):
```js
module: {
loaders: [
{test: /\.png$/, loader: "file-loader"},
{
test: /\.html$/,
exclude: /index.html$/, // you need to exclude your base template (unless you do not want this plugin own templating feature)
loader: "html"
}
]
}
```
This configuration allows you to require partial html from your main `index.html` without being itself parsed by the html-loader instead of this html-webpack-plugin.
## Custom template engines
Maybe you prefer jade or blueimp over underscore - or your project is using jade for the front end part.