sagold / handlebars-webpack-plugin

Renders your html-template at build time
161 stars 45 forks source link

Handlebars escaping content even when using {{{ #6

Closed Cosmicist closed 7 years ago

Cosmicist commented 7 years ago

It seems that handlebars compiler is removing any html even when using the "triple-stash" {{{.

I have this in my template <h1>{{{title}}}</h1> and in my data file I have {"title": "Foo<br>bar"}, yet the title is stripped of any html, ending as plainly as Foo bar.

Here's my webpack.config.js file:

var debug = process.env.NODE_ENV !== "prod";
var page = process.env.PAGE || 'page-name';
var webpack = require('webpack');
var HbsPlugin = require('handlebars-webpack-plugin');

var hbsPlugin = new HbsPlugin({
    entry: __dirname + '/src/index.hbs',
    output: __dirname + '/dist/index.html',
    data: require('./src/data.json')[page]
});

module.exports = {
    entry: __dirname + "/src/app.js",
    output: {
        path: __dirname + "/dist",
        filename: "app.min.js"
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                query: { presets: ['es2015'] }
            }
        ]
    },
    plugins: debug
        ? [
            hbsPlugin
        ]
        : [
            hbsPlugin,
            new webpack.optimize.DedupePlugin(),
            new webpack.optimize.OccurenceOrderPlugin(),
            new webpack.optimize.UglifyJsPlugin({ mangle: false }),
        ]
};

Am I doing something wrong?

Thanks!

Cosmicist commented 7 years ago

Nevermind, my bad, I had the data file wrong :/