gulp-hogan

2.0.0 • Public • Published

gulp-hogan Build status

gulp plugin to compile hogan templates.

Usage

First, install gulp-hogan as a development dependency:

npm install --save-dev gulp-hogan

Then, add it to your gulpfile.js:

Say our template.hogan is :

Follow @{{handle}}.
var hogan = require('gulp-hogan');
 
gulp.task('default', function(){
  gulp.src('template.hogan')
    .pipe(hogan({handle: 'gnumanth'}))
    .pipe(gulp.dest('dist'));
});

Now dist will have template.js with content as Follow @gnumanth

Template inheritance & Partials

Partials will be rendered recursively, allowing for template inheritance.

Example:

Folder structure

|-- templates
    |-- page.hogan
    |-- body.hogan
    |-- partials
    |   |-- header.hogan
    |   |-- footer.hogan

page.hogan

<h1>Page</h1>
{{> body }}

body.hogan

{{> partials/header }}
{{> partials/footer }}

header.hogan

<header>
    Logo {{#image}}<img>{{/image}}
</header>

footer.hogan

<footer>
    Copyright {{year}}
</footer>

gulpfile.js

var hogan = require('gulp-hogan');
 
gulp.task('default', function(){
  gulp.src('template/page.hogan', {}, '.html')
    .pipe(hogan({year: '2016'}, null, '.html'))
    .pipe(gulp.dest('dist'));
});

dist/page.html

<h1>Page</h1>
<header>
    Logo <img>
</header>
<footer>
    Copyright 2016
</footer>

Package Sidebar

Install

npm i gulp-hogan

Weekly Downloads

2

Version

2.0.0

License

BSD-2-Clause

Last publish

Collaborators

  • ericyd
  • hemanth