shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.
http://npm.im/gulp-hb
MIT License
147 stars 14 forks source link

Cross-contamination when running multiple gulp tasks that use gulp-hb #29

Closed gligoran closed 8 years ago

gligoran commented 8 years ago

I'm using gulp-hp to build email templates. For each template I build 2 a text version and an html version. To make this work, I have 2 sets of partials. One for each version. In order for the core templates to work with both sets, the partials need to have the same names.

I've set up gulp watch, so I don't need to run the tasks manually. If I change any of the core templates, both tasks trigger. At almost the same time. The problem is that the one that started second (by a few milliseconds), will overwrite the partials, and I end up with both versions of the templates being the same.

The cause of this seems to be, the glup-hb registers the partials and the helpers globally. The task that started first loads its partials, but then the other tasks loads its partials, overwriting those of the first task. The end result is that first tasks will render templates using the partials of the second task.

I think each task, and in turn each call to .pipe(hb(...)), should have its own set of registered partials, helpers...

shannonmoeller commented 8 years ago

This is a good idea. Would likely address #24 as well.

shannonmoeller commented 8 years ago

I have a v3 release candidate ready that should address this issue. Are you available to kick the tires?

npm i --save "shannonmoeller/gulp-hb#v3"
shannonmoeller commented 8 years ago

Released as v3.0.0

gligoran commented 8 years ago

Sorry, for being late to the party. It works like a charm now. More gulp watch parallelization for me :)

shannonmoeller commented 8 years ago

Thanks for confirming!