esamattis/node-hbsfy

Errors on comments

megawac opened this issue · 4 comments

Consider the template

template.js

{{!-- a comment --}}
<div class="smt"></div>

app.js

module.exports = {
   template: require("./template.hbs")
};

Compiling will give an error something like (using slightly different templates):

Error: Parsing file /home/gyeates/Dropbox/clearpath/LoLoch/assets/templates/nav.hbs: Line 2: Unexpected identifier
    at Deps.parseDeps (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/browserify/node_modules/module-deps/index.js:339:28)
    at /home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/browserify/node_modules/module-deps/index.js:282:29
    at ConcatStream.<anonymous> (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/browserify/node_modules/concat-stream/index.js:32:43)
    at ConcatStream.emit (events.js:117:20)
    at finishMaybe (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/readable-stream/lib/_stream_writable.js:460:14)
    at endWritable (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
    at ConcatStream.Writable.end (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
    at DuplexWrapper.onend (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
    at DuplexWrapper.g (events.js:180:16)
    at DuplexWrapper.emit (events.js:117:20)

I'm not able to reproduce this issue. See 3472630

Make sure your Handlebars version actually supports comments.

I'll try to make a failing test case after I finish a meeting
On Oct 16, 2014 11:13 AM, "Esa-Matti Suuronen" notifications@github.com
wrote:

https://travis-ci.org/epeli/node-hbsfy/builds/38166881


Reply to this email directly or view it on GitHub
#36 (comment).

It looks like it's an issue with gulp-browserify. I can't reproduce the error calling the scripts with browserify cli

Works...

browserify -t hbsfy assets/js/app.js

gulpfile

var hsbfy = require("hsbfy");
gulp.task('js', function() {
  return gulp.src('./assets/js/app.js')
    .pipe(browserify({
      transforms: [hbsfy]
    }))
    .pipe(gulp.dest(buildFolder + '/js'));
});
gyeates@nb-gyeates:clearpath/LoLoch $ gulp js                                                                                                      12:25
[12:25:11] Using gulpfile ~/Dropbox/clearpath/LoLoch/gulpfile.js
[12:25:11] Starting 'js'...

events.js:72
        throw er; // Unhandled 'error' event
              ^
SyntaxError in plugin 'gulp-browserify'

/home/gyeates/Dropbox/clearpath/LoLoch/assets/templates/nav.hbs:7
  {{! Collect the nav links, forms, and other content for toggling }}
    ^
ParseError: Unexpected token !
    at wrapWithPluginError (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/index.js:44:10)
    at Stream.<anonymous> (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/index.js:123:28)
    at Stream.<anonymous> (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/browserify/index.js:344:22)
    at Stream.emit (events.js:117:20)
    at Transform.onerror (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/browserify/node_modules/stream-combiner/index.js:29:18)
    at Transform.emit (events.js:117:20)
    at onwriteError (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:250:10)
    at onwrite (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:268:5)
    at WritableState.onwrite (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:106:5)
    at afterTransform (/home/gyeates/Dropbox/clearpath/LoLoch/node_modules/gulp-browserify/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:104:5)

Going to open an issue elsewhere, sorry about that