@@ -32,7 +32,8 @@ Advanced alternative to [html-webpack-plugin](https://github.com/jantimon/html-w
3232- An [ entry point] ( #option-entry ) is any HTML template. ** Start from HTML** , not from JS.
3333- ** Find** and automatic processing of templates in the [ entry directory] ( #option-entry-path ) .
3434- ** Renders** the [ template engines] ( #template-engine ) "out of the box":
35- [ Eta] ( #using-template-eta ) , [ EJS] ( #using-template-ejs ) , [ Handlebars] ( #using-template-handlebars ) , [ Nunjucks] ( #using-template-nunjucks ) , [ Pug] ( #using-template-pug ) , [ TwigJS] ( #using-template-twig ) , [ LiquidJS] ( #using-template-liquidjs ) .
35+ [ Eta] ( #using-template-eta ) , [ EJS] ( #using-template-ejs ) , [ Handlebars] ( #using-template-handlebars ) , [ Nunjucks] ( #using-template-nunjucks ) , [ Pug] ( #using-template-pug ) , [ Tempura] ( #using-template-tempura ) , [ TwigJS] ( #using-template-twig ) , [ LiquidJS] ( #using-template-liquidjs ) .
36+ It is very easy to add support for any template engine.
3637- ** Source files** of [ ` script ` ] ( #option-js ) and [ ` style ` ] ( #option-css ) can be specified directly in HTML:
3738 - ` <link href="./style.scss" rel="stylesheet"> ` \
3839 No longer need to define source style files in Webpack entry or import styles in JavaScript.
@@ -495,6 +496,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
495496 - [ eta] ( #loader-option-preprocessor-options-eta )
496497 - [ ejs] ( #loader-option-preprocessor-options-ejs )
497498 - [ handlebars] ( #loader-option-preprocessor-options-handlebars )
499+ - [ tempura] ( #loader-option-preprocessor-options-tempura )
498500 - [ nunjucks] ( #loader-option-preprocessor-options-nunjucks )
499501 - [ pug] ( #loader-option-preprocessor-options-pug )
500502 - [ twig] ( #loader-option-preprocessor-options-twig )
@@ -508,6 +510,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
508510 - [ Mustache] ( #using-template-mustache )
509511 - [ Nunjucks] ( #using-template-nunjucks )
510512 - [ Pug] ( #using-template-pug )
513+ - [ Tempura] ( #using-template-tempura )
511514 - [ TwigJS] ( #using-template-twig )
5125151 . [ Using template in JavaScript] ( #template-in-js )
5135161 . [ Setup Live Reload] ( #setup-live-reload )
@@ -3657,6 +3660,60 @@ For the complete list of Handlebars `compile` options see [here](https://handleb
36573660
36583661#### [↑ back to contents](#contents)
36593662
3663+
3664+ < a id= " loader-option-preprocessor-options-tempura" name= " loader-option-preprocessor-options-tempura" >< / a>
3665+
3666+ #### Options for ` preprocessor: 'tempura'`
3667+
3668+ [Tempura](https: // github.com/lukeed/tempura) is a light and fast template engine with Handlebars-like syntax.
3669+
3670+ The preprocessor has built- in ` include` helper, to load a partial file.
3671+
3672+ ` ` ` js
3673+ {
3674+ preprocessor: 'tempura',
3675+ preprocessorOptions: {
3676+ // defaults process.cwd(), root path for includes with an absolute path (e.g., /file.html)
3677+ root: path.join(__dirname, 'src/views/'), // defaults process.cwd()
3678+ // defaults [], an array of paths to use when resolving includes with relative paths
3679+ views: [
3680+ 'src/views/includes', // relative path
3681+ path.join(__dirname, 'src/views/partials'), // absolute path
3682+ ],
3683+ blocks: {
3684+ // define here custom helpers
3685+ bar: ({ value }) => ` < bar> ${value}< / bar> ` ,
3686+ },
3687+ },
3688+ },
3689+ ` ` `
3690+
3691+ For all available options, see the [Tempura API options](https: // github.com/lukeed/tempura/blob/master/docs/api.md#options-2).
3692+
3693+ ** Using build- in ` include` helper.**
3694+
3695+ The ` src` attribute contains a path to the partial file.
3696+
3697+ The path relative to current working directory (defaults webpack config directory):
3698+
3699+ ` ` ` hbs
3700+ {{#include src='src/views/partials/header.hbs' }}
3701+ ` ` `
3702+
3703+ The path relative to directory defined in ` root` option, e .g . ` root: 'src/view'` :
3704+ ` ` ` hbs
3705+ {{#include src='partials/header.hbs' }}
3706+ ` ` `
3707+
3708+ The path relative to one of directories defined in ` views` option, e .g . ` views: ['src/views/partials']` :
3709+ ` ` ` hbs
3710+ {{#include src='header.hbs' }}
3711+ ` ` `
3712+
3713+ -- -
3714+
3715+ #### [↑ back to contents](#contents)
3716+
36603717< a id= " loader-option-preprocessor-options-nunjucks" name= " loader-option-preprocessor-options-nunjucks" >< / a>
36613718
36623719#### Options for ` preprocessor: 'nunjucks'`
@@ -3917,6 +3974,7 @@ Using the [preprocessor](#loader-option-preprocessor), you can compile any templ
39173974- [Mustache](https: // github.com/janl/mustache.js)
39183975- [Nunjucks](https: // mozilla.github.io/nunjucks/)
39193976- [Pug](https: // pugjs.org)
3977+ - [Tempura](https: // github.com/lukeed/tempura)
39203978- [TwigJS](https: // github.com/twigjs/twig.js)
39213979
39223980<!--
@@ -4121,12 +4179,85 @@ module.exports = {
41214179
41224180See the [` handlebars` preprocessor options](#loader- option- preprocessor- options- handlebars).
41234181
4124- [Source code](https: // github.com/webdiscus/html-bundler-webpack-plugin/tree/master/examples/handlebars/)
4182+ [Source code of the example ](https: // github.com/webdiscus/html-bundler-webpack-plugin/tree/master/examples/handlebars/)
41254183
41264184[! [Open in StackBlitz](https: // developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/webpack-webpack-js-org-mxbx4t?file=webpack.config.js)
41274185
41284186#### [↑ back to contents](#contents)
41294187
4188+ < a id= " using-template-tempura" name= " using-template-tempura" >< / a>
4189+
4190+ ### Using the Tempura
4191+
4192+ You need to install the ` tempura` package:
4193+
4194+ ` ` `
4195+ npm i -D tempura
4196+ ` ` `
4197+
4198+ For example, there is the template _src/ views/ page/ home .hbs_
4199+
4200+ ` ` ` hbs
4201+ <!DOCTYPE html>
4202+ <html>
4203+ <head>
4204+ <title>{{ title }}</title>
4205+ </head>
4206+ <body>
4207+ {{#include src='header.hbs' }}
4208+ <div class="container">
4209+ <h1>Tempura</h1>
4210+ <div>{{ persons.length }} persons:</div>
4211+ <ul class="person">
4212+ {{#each persons as person}}
4213+ <li>{{person.name}} is {{person.age}} years old.</li>
4214+ {{/each}}
4215+ </ul>
4216+ </div>
4217+ {{#include src='footer.hbs' }}
4218+ </body>
4219+ </html>
4220+ ` ` `
4221+
4222+ Define the ` preprocessor` as ` tempura` :
4223+
4224+ ` ` ` js
4225+ const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
4226+
4227+ module.exports = {
4228+ plugins: [
4229+ new HtmlBundlerPlugin({
4230+ entry: {
4231+ // define templates here
4232+ index: {
4233+ import: 'src/views/pages/home.hbs', // => dist/index.html
4234+ // pass data to template as an object
4235+ data: {
4236+ title: 'Tempura',
4237+ persons: [
4238+ { name: 'Robert', age: 30 },
4239+ ...
4240+ ],
4241+ },
4242+ },
4243+ },
4244+ // use tempura templating engine
4245+ preprocessor: 'tempura',
4246+ // define options
4247+ preprocessorOptions: {
4248+ views: ['src/views/partials'],
4249+ },
4250+ }),
4251+ ],
4252+ };
4253+ ` ` `
4254+
4255+ See the [` tempura` preprocessor options](#loader- option- preprocessor- options- tempura).
4256+
4257+ [Source code of the example](https: // github.com/webdiscus/html-bundler-webpack-plugin/tree/master/examples/tempura/)
4258+
4259+ #### [↑ back to contents](#contents)
4260+
41304261< a id= " using-template-mustache" name= " using-template-mustache" >< / a>
41314262
41324263### Using the Mustache
0 commit comments