shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.

Home Page:http://npm.im/gulp-hb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

gligoran opened this issue · comments

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...

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

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"

Released as v3.0.0

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

Thanks for confirming!