gulp-hb icon indicating copy to clipboard operation
gulp-hb copied to clipboard

compileOptions: noEscape is not working

Open uxmoon opened this issue 4 years ago • 2 comments

Hi! I have this function setup to compile my hbs files and I'm using a data.json file for the content.

The problem is that I'm trying to use the compileOptions with noEscape set to true but the HTML markup in the .json file is escaped.

My function is the following:

function compileHbs() {

  const hbStream = hb({
      compileOptions: {
        noEscape: true
      }
    })
    .partials('src/html/**/*.hbs')
    .data('src/data.json');

  return gulp
    .src('src/index.hbs')
    .pipe(hbStream)
    .pipe(rename('index.html'))
    .pipe(gulp.dest(folder.build));
}

Any help or hint will be appreciated, thanks!

Edit: Using a triple {{{ is not an option for my project.

uxmoon avatar Oct 29 '19 18:10 uxmoon

Well that's a problem. I don't have time at the moment to dig into it, but I was able to reproduce your issue. My hunch is that the issue is in the underlying handlebars-wax library. Fortunately, I wrote that too.

I think these are the offending lines:

https://github.com/shannonmoeller/handlebars-wax/blob/master/index.js#L40 https://github.com/shannonmoeller/handlebars-wax/blob/master/index.js#L259

shannonmoeller avatar Oct 30 '19 15:10 shannonmoeller

I think I'll need to rewrite handlebars-wax to remove the use of require hooks. Especially with unflagged import support coming in Node 12.7.

shannonmoeller avatar Oct 30 '19 15:10 shannonmoeller