Skip to content

Latest commit

 

History

History
67 lines (49 loc) · 1.64 KB

README.md

File metadata and controls

67 lines (49 loc) · 1.64 KB

gulp-ractive Build Status

Installation and Ractive versions

This branch of the plugin uses ractive 0.9.x. To install this version, use:

npm install [email protected] --save-dev

Usage

Simple example:

var gulp = require('gulp'),
	ractive = require('gulp-ractive');

gulp.task('ractive_templates', function() {
	return gulp.src('templates/*.ractive')
		.pipe(ractive())
		.pipe(gulp.dest('templates/compiled/'));
});

Using options

var gulp = require('gulp'),
	ractive = require('gulp-ractive');

gulp.task('ractive_templates', function() {
	return gulp.src('templates/*.ractive')
		.pipe(ractive({
		  preserveWhitespace: true
		}))
		.pipe(gulp.dest('templates/compiled/'));
});

Example with compiled files in the same folder (using gulp-rename):

var gulp = require('gulp'),
	rename = require('gulp-rename'),
	ractive = require('gulp-ractive');

gulp.task('ractive_templates', function() {
	return gulp.src('templates/*.ractive')
		.pipe(ractive())
		.pipe(rename({
			extname: ".ractivecompiled",
		}))
		.pipe(gulp.dest('templates/'));
});

Error handling

There's no need to use gulp-plumber to catch errors, gulp-ractive logs errors using console.warn instead of crashing gulp.

Options

You can pass to ractive() the same options that you pass when creating a new Ractive object (see the docs from ractivejs.org: http://docs.ractivejs.org/latest/options).

Remember that not all options are meaningful to Ractive.parse() (eg: data or computed).