gulp-hb
gulp-bh
simply to base it off of a remote fs (s3)
This is a fork of A sane static Handlebars Gulp plugin. Useful as a static site generator. Powered by handlebars-wax
. Think Assemble, but with a lot less Jekyll baggage.
For Grunt, see grunt-hb
. To precompile templates into JavaScript, see gulp-handlebars
.
Install
npm install --save-dev gulp-hb
Usage
var gulp = ;var hb = ; // Basic gulp; // Advanced gulp;
Template Context
The template context is a merge of pre-registered data and file-specific data. Pre-registered data is available to all templates and is set using the .data()
method. File-specific data is available to the current template and is set via the file.data
property.
@
Data Variables
@root
The merged object of pre-registered data and file-specific data is available as the primary context of your templates. In cases where accessing this data would require the use of ../
, you may access the top-level context via @root
:
{{ foo }}{{ @root.foo }} {{#each bar}} {{ ../foo }} {{ @root.foo }}{{/each}}
@global
In cases where file-specific data keys collide with pre-registered data keys, you may access the pre-registered data via @global
:
{{ @global.foo }}
@local
In cases where pre-registered data should be ignored, you may access the file-specific data via @local
.
{{ @local.foo }}
@file
In cases where information about the template file itself is needed, you may access the file object via @file
:
{{ @file.path }}
File-specific Data Sources
File-specific data is set via the file.data
property using other plugins such as gulp-data
, gulp-data-json
, or gulp-front-matter
.
var gulp = ;var data = ;var frontMatter = ;var hb = ; gulp
Multiple Data Sources
Multiple data sources can be used to render the same set of templates to different directories using through2
.
var gulp = ;var hb = ;var through = ; gulp;
API
hb([options]): TransformStream
options
{Object}
(optional) Passed directly tohandlebars-wax
so check there for more options.bustCache
{Boolean}
(default:true
) Force reload data, partials, helpers, and decorators.cwd
{String}
(default:process.cwd()
) Current working directory.debug
{Boolean|Number}
(default:false
or0
) Whether to log registered functions and data (true
or1
) and glob parsing (2
).handlebars
{Handlebars}
(optional) A specific instance of Handlebars, if needed.compileOptions
{Object}
Options to use when compiling templates.templateOptions
{Object}
Options to use when rendering templates.partials
{String|Array.<String>|Object|Function(handlebars)}
parsePartialName
{Function(options, file): String}
helpers
{String|Array.<String>|Object|Function(handlebars)}
parseHelperName
{Function(options, file): String}
decorators
{String|Array.<String>|Object|Function(handlebars)}
parseDecoratorName
{Function(options, file): String}
data
{String|Array.<String>|Object}
parseDataName
{Function(options, file): String}
Returns a Gulp-compatible transform stream that compiles Handlebars templates to static output.
.partials(pattern [, options]): TransformStream
pattern
{String|Array<String>|Object|Function(handlebars)}
options
{Object}
Same options ashb()
.
Loads additional partials. See handlebars-wax
.
.helpers(pattern [, options]): TransformStream
pattern
{String|Array<String>|Object|Function(handlebars)}
options
{Object}
Same options ashb()
.
Loads additional helpers. See handlebars-wax
.
.decorators(pattern [, options]): TransformStream
pattern
{String|Array<String>|Object|Function(handlebars)}
options
{Object}
Same options ashb()
.
Loads additional decorators. See handlebars-wax
.
.data(pattern [, options]): TransformStream
pattern
{String|Array<String>|Object}
options
{Object}
Same options ashb()
.
Loads additional data. See handlebars-wax
.
Contribute
Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.
Test
$ npm test
© Shannon Moeller me@shannonmoeller.com (shannonmoeller.com)
Licensed under MIT