Coder Social home page Coder Social logo

gulp-ejs's Introduction

gulp-ejs NPM version Build Status Dependency Status

ejs plugin for gulp

Usage

First, install gulp-ejs as a development dependency:

npm install --save-dev gulp-ejs

Then, add it to your gulpfile.js:

var ejs = require("gulp-ejs");

gulp.src("./templates/*.ejs")
	.pipe(ejs({
		msg: "Hello Gulp!"
	}))
	.pipe(gulp.dest("./dist"));

If you want to use gulp-ejs in a watch/livereload task, you may want to avoid gulp exiting on error when, for instance, a partial file is ENOENT. Here's an example on how to make it work:

var ejs = require('gulp-ejs');
var gutil = require('gulp-util');

gulp.src('./templates/*.ejs')
	.pipe(ejs({
		msg: 'Hello Gulp!'
	}).on('error', gutil.log))
	.pipe(gulp.dest('./dist'));

This will make gulp log the error and continue normal execution.

API

ejs(options, settings)

options

Type: hash Default: {}

A hash object where each key corresponds to a variable in your template. Also you can set ejs options in this hash.

For more info on ejs options, check the project's documentation.

Note: As of v1.2.0, file.data is supported as a way of passing data into ejs. See this.

settings

Type: hash Default: {}

A hash object to configure the plugin.

settings.ext

Type: String Default: undefined

Defines the file extension that will be appended to the filename. If no extension is provided, the same extension of the input file will be used.

Note: As of v2.0.0 the output file extension is no longer .html by default, you need to specify it, otherwise it will have the same extension of the input file.

License

MIT License

gulp-ejs's People

Contributors

abrkn avatar broud avatar elct9620 avatar greenkeeperio-bot avatar jtomaszewski avatar kilianc avatar pdehaan avatar rogeriopvl avatar tomchentw avatar

Watchers

 avatar  avatar  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.