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

clarify what should be output with debug? #50

Closed mmilano closed 7 years ago

mmilano commented 7 years ago

hi, trying and struggling to use gulp-hb and your associated handlebars-layout (hb-layout?). w/r/t gulp-hb, can you add more clarification and detail to what the debug parameter will do, and what the contents of the various out sections should display?

in particular:

thanks.

right now, a run will give me something like this:

pages/project.html
    global data:
      Volumes        site           sitePortfolio  
    local data:

    decorators:
      inline  
    helpers:
      blockHelperMissing  helperMissing       log                 unless              
      each                if                  lookup              with                
    partials:
      project-a            project-css             project-header               project-section-heading-4  
      project-figure               project-font            project-js                   
      project-ico             project-section-heading-2  
      project-foor               project-meta            project-section-heading-3  
shannonmoeller commented 7 years ago

The purpose of the debug flag is to give a quick glimpse into the state of Handlebars when a file is rendered. This can be useful to tell if a glob pattern has converted into the state you expect to be there when writing your templates.

debug

The debug flag can be a Boolean or a Number:

When the debug flag is not 0 or false, gulp-hb will log the top-level object keys (like your example) for pertinent internal Handlebars objects where the list is the result of running Object.keys(handlebars[property]):

global data

Top-level object keys of data that was registered using hb({ data: ... }) or the .data() method. Gives you a sense of what you can access at the root-level of your templates using {{foo}} or {{@global.foo}}. In your case you'd be able to access {{site}}, {{@global.sitePortfolio}}, etc.

local data

Top-level object keys of data passed into the template at render time. This will be the file.data property if it exists. Gives you a sense of what you can access at the local-level of your templates using {{foo}} or {{@local.foo}}. In your case, you haven't used a plugin to populate the file.data property.

decorators, helpers, and partials

Top-level object keys of Handlebars registries. Same as Object.keys(handlebars.partials) to list registered partials for example. The blockHelperMissing and helperMissing helpers are not errors, but are default internal Handlebars helpers.


The handlebars-layouts module is separate, though, as the author, I often include it. :)

mmilano commented 7 years ago

thank you!

shannonmoeller commented 7 years ago

Of course!