shannonmoeller / gulp-hb

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

Partials as array get wrong namespace #55

Closed MickL closed 7 years ago

MickL commented 7 years ago

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: [...]})

MickL commented 7 years ago

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

shannonmoeller commented 7 years ago

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.