All Projects → shannonmoeller → Gulp Hb

shannonmoeller / Gulp Hb

Licence: mit
A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Hb

Gulp Site Generator
A static site generator using Gulp
Stars: ✭ 183 (+26.21%)
Mutual labels:  gulp, static-site-generator, handlebars
startover
Startover is a boilerplate for developing static websites. With Startover you don't have to start over!
Stars: ✭ 15 (-89.66%)
Mutual labels:  gulp, handlebars
Gulp Webpack Starter
Gulp Webpack Starter - fast static website builder. The starter uses gulp toolkit and webpack bundler. Download to get an awesome development experience!
Stars: ✭ 199 (+37.24%)
Mutual labels:  gulp, static-site-generator
generator-veams
Scaffold modern frontend web apps or web pages with a static site generator (Assemble or Mangony), Grunt and/or Gulp, Sass and Bower. Use modern frameworks like Bourbon, Bootstrap or Foundation and structure your JavaScript with ES Harmony support.
Stars: ✭ 45 (-68.97%)
Mutual labels:  gulp, static-site-generator
Gopablo
🐺 Static site generator.
Stars: ✭ 166 (+14.48%)
Mutual labels:  gulp, static-site-generator
Hugo theme pickles
Modern, Simple and beautiful Hugo theme
Stars: ✭ 168 (+15.86%)
Mutual labels:  gulp, static-site-generator
bymattlee-11ty-starter
A starter boilerplate powered by 11ty, Sanity, Gulp, Tailwind CSS, rollup.js, Alpine.js and Highway.
Stars: ✭ 27 (-81.38%)
Mutual labels:  gulp, static-site-generator
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (-47.59%)
Mutual labels:  gulp, static-site-generator
stacy
Website generator that combines content from Contentful CMS with Handlebars templates and publishes the website in Amazon S3.
Stars: ✭ 24 (-83.45%)
Mutual labels:  static-site-generator, handlebars
bootstrap-gulp-starter-template
Bootstrap 4 + Gulp 4 + Panini for improve front-end development workflow
Stars: ✭ 67 (-53.79%)
Mutual labels:  gulp, handlebars
Baumeister
👷 The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
Stars: ✭ 171 (+17.93%)
Mutual labels:  static-site-generator, handlebars
Assemble
Community
Stars: ✭ 3,995 (+2655.17%)
Mutual labels:  gulp, static-site-generator
lnv-mobile-base
移动端开发脚手架-基于gulp的使用zepto、handlebars、sass并且带移动端适配方案(flexible.js)的前端工作流,旨在帮助移动端项目的开发
Stars: ✭ 41 (-71.72%)
Mutual labels:  gulp, handlebars
hugo-gulp-template
Enhanced template for Hugo projects
Stars: ✭ 28 (-80.69%)
Mutual labels:  gulp, static-site-generator
Publii
Publii is a desktop-based CMS for Windows, Mac and Linux that makes creating static websites fast and hassle-free, even for beginners.
Stars: ✭ 3,644 (+2413.1%)
Mutual labels:  static-site-generator, handlebars
Panini
A super simple flat file generator.
Stars: ✭ 562 (+287.59%)
Mutual labels:  gulp, handlebars
Uswds Site
USWDS website and documentation
Stars: ✭ 135 (-6.9%)
Mutual labels:  gulp
Gatsby Starter Try Ghost
Publish flaring fast blogs with Gatsby and Ghost
Stars: ✭ 137 (-5.52%)
Mutual labels:  static-site-generator
Publiccms
现代化java cms,由天津黑核科技有限公司开发,轻松支撑千万数据、千万PV;支持静态化,服务器端包含; 目前已经拥有全球0.0002%的用户,语言支持中、繁、日、英;是一个已走向海外的成熟CMS产品
Stars: ✭ 1,750 (+1106.9%)
Mutual labels:  static-site-generator
Gulp Starter Kit
A simple Gulp 4 Starter Kit for modern web development.
Stars: ✭ 134 (-7.59%)
Mutual labels:  gulp

gulp-hb

NPM version Downloads Build Status Coverage Status Tip

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.

To precompile templates into JavaScript, see gulp-handlebars.

Install

$ npm install --save-dev gulp-hb

Usage

const gulp = require('gulp');
const hb = require('gulp-hb');

// Basic

function basic() {
    return gulp
        .src('./src/{,posts/}*.html')
        .pipe(hb()
            .partials('./src/assets/partials/**/*.hbs')
            .helpers('./src/assets/helpers/*.js')
            .data('./src/assets/data/**/*.{js,json}')
        )
        .pipe(gulp.dest('./web'));
}

gulp.task('basic', basic);

// Advanced

function advanced() {
    const hbStream = hb({ debug: true })
        // Partials
        .partials('./partials/components/**/*.{hbs,js}')
        .partials('./partials/layouts/**/*.{hbs,js}')
        .partials({
            boo: '{{#each boo}}{{greet}}{{/each}}',
            far: '{{#each far}}{{length}}{{/each}}'
        })

        // Helpers
        .helpers(require('handlebars-layouts'))
        .helpers('./helpers/**/*.js')
        .helpers({
            foo: function () { ... },
            bar: function () { ... }
        })

        // Decorators
        .decorators('./decorators/**/*.js')
        .decorators({
            baz: function () { ... },
            qux: function () { ... }
        })

        // Data
        .data('./data/**/*.{js,json}')
        .data({
            lorem: 'dolor',
            ipsum: 'sit amet'
        });

    return gulp
        .src('./src/{,posts/}*.html')
        .pipe(hbStream)
        .pipe(gulp.dest('./web'));
}

gulp.task('advanced', advanced);

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.

const gulp = require('gulp');
const data = require('gulp-data');
const frontMatter = require('gulp-front-matter');
const hb = require('gulp-hb');

function inject() {
    return gulp
        .src('./src/*.html')

        // Load an associated JSON file per post.
        .pipe(data((file) => {
            return require(file.path.replace('.html', '.json'));
        }))

        // Parse front matter from post file.
        .pipe(frontMatter({
            property: 'data.frontMatter'
        }))

        // Data for everyone.
        .pipe(hb().data('./data/**/*.js'))

        .pipe(gulp.dest('./web'));
}

gulp.task('inject', inject);

Multiple Data Sources

Multiple data sources can be used to render the same set of templates to different directories using through2.

const gulp = require('gulp');
const hb = require('gulp-hb');
const through = require('through2');

function i18n() {
    return gulp
        .src('./i18n/*.json')
        .pipe(through.obj((file, enc, cb) => {
            const locale = file.stem;
            const data = {
                locale: locale,
                i18n: JSON.parse(file.contents.toString())
            };

            gulp
                .src('./templates/**/*.html')
                .pipe(hb().data(data))
                .pipe(gulp.dest('./dist/' + locale))
                .on('error', cb)
                .on('end', cb);
        }));
}

gulp.task('i18n', i18n);

API

hb([options]): TransformStream

  • options {Object} (optional) Passed directly to handlebars-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 or 0) Whether to log registered functions and data (true or 1) 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 as hb().

Loads additional partials. See handlebars-wax.

.helpers(pattern [, options]): TransformStream

  • pattern {String|Array<String>|Object|Function(handlebars)}
  • options {Object} Same options as hb().

Loads additional helpers. See handlebars-wax.

.decorators(pattern [, options]): TransformStream

  • pattern {String|Array<String>|Object|Function(handlebars)}
  • options {Object} Same options as hb().

Loads additional decorators. See handlebars-wax.

.data(pattern [, options]): TransformStream

  • pattern {String|Array<String>|Object}
  • options {Object} Same options as hb().

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

MIT © Shannon Moeller

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].