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

Add each 'file' to an array (e.g files) accessible in each page

spacedawwwg opened this issue · comments

If tried to figure tis out, but have come up short.

Is is possible to access each 'file' from within a handlebars page? e.g:

{{#each files}}
<li><a href="{{path}}">{{basename}}</a></li>
{{/each}]

This is one drawback to gulp. It processes files one at a time, so there's no way to get the whole picture and deliver it to files one by one in a single step. I usually solve this by creating a separate script that gathers the file info I need, then include that in the data: property:

.pipe(hb({
    data: './data/navTree.js',
    ...
}))

Since switching obver to gulp, everything seems to be more awkward

...back to the drawing board on this one.

To gulp in general, or to gulp-hb specifically? If the former, you might like broccoli as it works on trees rather than individual files. If the latter, what are your pain points?

Sorry, gulp in general!! gulp-hb + handlebars-layouts have been my saviours!

gulp-hb is 'exactly' what I need as I use it to create flat 'demo' pages of HTML for clients before integrating them into CMS templates. The only reason I needed an {{#each pages}} like assemble was to create a 'listing` page of all the files (but use the front matter as well)

Apologies for being grumpy in my previous comment.

No worries! Just didn't want to be the reason you're leaning away from gulp. :) And for what it's worth, there's a gulp plugin called gulp-nav that can do what you'd like to do. I'm not a huge fan because it queues up all of the files and their contents into memory, then re-emits them on flush (ouch). But, it does what you'd like to do. I created an example.