diff --git a/index.js b/index.js index e74c4eb..5a4fb9f 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,8 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { compilation.errors.push(new Error('HtmlWebpackPlugin: cannot specify both template and templateContent options')); callback(); } else if (self.options.templateContent) { - self.emitHtml(compilation, self.options.templateContent, templateParams, outputFilename); + var templateContent = typeof self.options.templateContent === 'function' ? self.options.templateContent(templateParams, compiler) : self.options.templateContent; + self.emitHtml(compilation, templateContent, templateParams, outputFilename); callback(); } else { var templateFile = self.options.template; diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index 091978c..45e5981 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -112,6 +112,22 @@ describe('HtmlWebpackPlugin', function() { ['