diff --git a/index.js b/index.js index 0f63ba3..4cda9ef 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,8 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) { compiler.errors.push(new Error('HtmlWebpackPlugin: cannot specify both template and templateContent options')); callback(); } else if (self.options.templateContent) { - self.emitHtml(compiler, self.options.templateContent, templateParams, outputFilename); + var templateContent = typeof self.options.templateContent === 'function' ? self.options.templateContent(templateParams, compiler) : self.options.templateContent; + self.emitHtml(compiler, templateContent, templateParams, outputFilename); callback(); } else { var templateFile = self.options.template; diff --git a/spec/HtmlWebpackPluginSpec.js b/spec/HtmlWebpackPluginSpec.js index e737806..fb3e162 100644 --- a/spec/HtmlWebpackPluginSpec.js +++ b/spec/HtmlWebpackPluginSpec.js @@ -83,6 +83,22 @@ describe('HtmlWebpackPlugin', function() { ['