Gulp Build for Handlebars Templating

0.5.3 · abandoned · verified Tue Apr 21

The package `gulp-build` (version 0.5.3) is a Gulp 3 plugin designed to process files by swapping in variables using Handlebars templates. It facilitates building files for different environments by dynamically injecting data like Google Analytics IDs or compiling static HTML. Key features include support for Handlebars helpers, partials, and layouts, which were introduced in version 0.5.0, replacing earlier Underscore template integration. The plugin's current version (0.5.3) dates back to 2014 based on the copyright notice in its README, suggesting a lack of recent development. Its release cadence is effectively halted. It differentiates itself by providing a simple Handlebars-based templating pipeline within a Gulp 3 workflow, though a noted limitation is that partials and layouts must be provided as raw strings rather than file globs. Given its age and the fact that Gulp itself has advanced significantly beyond version 3, this package is effectively abandoned and may not be compatible with modern Gulp setups.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `gulp-build` to process HTML files using Handlebars with dynamic data, partials, and a layout.

const gulp = require('gulp');
const build = require('gulp-build');
const path = require('path');

// Pre-requisites:
// 1. Create a 'src' directory in your project root.
// 2. Inside 'src', create 'index.html' with content like: <h1>Hello, {{title}}!</h1>\n{{> footer}}
// 3. Run `npm install --save-dev gulp gulp-build`

const buildOptions = {
  partials: [{
    name: 'footer',
    tpl: '<p>Copyright 2013 by My Company</p>'
  }],
  layout: '<html><head><title>{{title}}</title></head><body>\n{{> body}}\n</body></html>'
};

gulp.task('build-html', function() {
  // Processes HTML files from the 'src' directory
  // and outputs them to a 'dist' directory.
  return gulp.src(path.join(__dirname, 'src', '*.html'))
      .pipe(build({ title: 'My Awesome Website' }, buildOptions))
      .pipe(gulp.dest(path.join(__dirname, 'dist')));
});

// To run this task, execute `gulp build-html` in your terminal.

view raw JSON →