Giter Club home page Giter Club logo

gulp-compile-handlebars's Introduction

gulp-compile-handlebars

Forked from gulp-template Inspired by grunt-compile-handlebars

Compile Handlebars templates

Install

Install with npm

npm install --save-dev gulp-compile-handlebars

Example

src/hello.handlebars

<h1>Hello {{firstName}}</h1>
<h2>HELLO! {{capitals firstName}}</h2>
{{> footer}}
{{> footer2}}

gulpfile.js

var gulp = require('gulp');
var handlebars = require('gulp-compile-handlebars');

gulp.task('default', function () {
	var templateData = {
		firstName: 'Kaanon'
	},
	options = {
		ignorePartials: true, //ignores the unknown footer2 partial in the handlebars template, defaults to false
		partials : {
			footer : '<footer>the end</footer>'
		},
		helpers : {
			capitals : function(str){
				return str.toUpperCase();	
			}
		}
	}

	return gulp.src('src/hello.handlebars')
		.pipe(handlebars(templateData, options))
		.pipe(rename('hello.html'))
		.pipe(gulp.dest('dist'));
});

dist/hello.html

<h1>Hello Kaanon</h1>
<h2>HELLO! KAANON</h2>
<footer>the end</footer>

Options

  • ignorePartials : ignores any unknown partials. Useful if you only want to handle part of the file
  • partials : Javascript object that will fill in partials using strings
  • batch : Javascript array of filepaths to use as partials
  • helpers: javascript functions to stand in for helpers used in the handlebars files

License

MIT © Kaanon MacFarlane

gulp-compile-handlebars's People

Contributors

kaanon avatar mathiasbynens avatar sindresorhus avatar vnys avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.