Skip to content

curtissimo/gulp-ractive

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-ractive

Installation and Ractive versions

The master branch (and the latest version on npm) is using Ractive 0.5.8, because of a bug that arise (ractivejs/ractive#1457) in Ractive 0.6 and is still not fixed in a release.

If you want to install this version, use:

npm install gulp-ractive --save-dev

If you want to use ractive 0.6.x, install the latest version.

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

About

compile Ractive templates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%