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

Partials as array get wrong namespace

MickL opened this issue · comments

I found some weird behavior:

When passing an array to .partials() then the first namespace is correct but the second shows the full path on disk:

.pipe(
   hb({debug: true})
       .partials([
         'src/components/partial1/partial1.hbs',
         'src/components/partial1/partial2.hbs'
      ])
   )
partials:
      /Users/mickL/Documents/git/myproject/src/components/partial2 
     partial1

If the first is using a wildcard then all of those are correct, but from the beginning its the full path again:

.partials(['src/components/shared/**/*.hbs', 'src/components/base.hbs'])

All the same for using hb({partials: [...]})

Workaround: Just import EVERYTHING as a partial: .partial('components/**/*.hbs')

You need to specify a base option for your first example:

hb({debug: true})
    .partials([
        'src/components/partial1/partial1.hbs',
        'src/components/partial1/partial2.hbs'
    ], {
        base: __dirname + '/src/components/partial1'
    })

Alternatively, your workaround is actually the intended and recommended means of registering partials.