var path = require('path');
var HtmlWebpackPlugin = require('../..');
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
module.exports = {
  context: __dirname,
  entry: './example.js',
  output: {
    path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),
    publicPath: '',
    filename: 'bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      // If you pass a plain object, it will be merged with the default values
      // (New in version 4)
      templateParameters: {
        'foo': 'bar'
      },
      // Or if you want full control, pass a function
      // templateParameters: (compilation, assets, assetTags, options) => {
      //   return {
      //     compilation,
      //     webpackConfig: compilation.options,
      //     htmlWebpackPlugin: {
      //       tags: assetTags,
      //       files: assets,
      //       options
      //     },
      //     'foo': 'bar'
      //   };
      // },
      template: 'index.ejs'
    })
  ]
};

var path = require('path');
var HtmlWebpackPlugin = require('../..');
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
module.exports = {
  context: __dirname,
  entry: './example.js',
  output: {
    path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),
    publicPath: '',
    filename: 'bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      // NOTE if you pass plain object it will be passed as is. no default values there, so be aware!
      // for implementation detail, please see index.js and search for "userOptions" variable
      templateParameters: (compilation, assets, assetTags, options) => {
        return {
          compilation,
          webpackConfig: compilation.options,
          htmlWebpackPlugin: {
            tags: assetTags,
            files: assets,
            options
          },
          'foo': 'bar'
        };
      },
      template: 'index.ejs'
    })
  ]
};

--- 
+++ 
@@ -11,20 +11,24 @@
   },
   plugins: [
     new HtmlWebpackPlugin({
-      // NOTE if you pass plain object it will be passed as is. no default values there, so be aware!
-      // for implementation detail, please see index.js and search for "userOptions" variable
-      templateParameters: (compilation, assets, assetTags, options) => {
-        return {
-          compilation,
-          webpackConfig: compilation.options,
-          htmlWebpackPlugin: {
-            tags: assetTags,
-            files: assets,
-            options
-          },
-          'foo': 'bar'
-        };
+      // If you pass a plain object, it will be merged with the default values
+      // (New in version 4)
+      templateParameters: {
+        'foo': 'bar'
       },
+      // Or if you want full control, pass a function
+      // templateParameters: (compilation, assets, assetTags, options) => {
+      //   return {
+      //     compilation,
+      //     webpackConfig: compilation.options,
+      //     htmlWebpackPlugin: {
+      //       tags: assetTags,
+      //       files: assets,
+      //       options
+      //     },
+      //     'foo': 'bar'
+      //   };
+      // },
       template: 'index.ejs'
     })
   ]
Update example to account for object merging

PR #1331 introduces new behavior that merges a passed object with the
defaults.
