0.2.2 • Published 11 years ago

gulp-render v0.2.2

Weekly downloads
7
License
-
Repository
github
Last release
11 years ago

gulp-render   Build Status Dependency Status Tips Gitter

Pre-render React components at compile time.

How to Install

NPM

$ npm install gulp-render --save-dev

How to Use

Example 1:

var gulp = require('gulp');
var render = require('gulp-render');

gulp.task('default', function() {
  return gulp.src('src/pages/**/*.jsx')
    .pipe(render({template: 'src/pages/_template.html'}))
    .pipe(gulp.dest('build'));
});

Example 2:

var gulp = require('gulp');
var render = require('gulp-render');

gulp.task('default', function() {
  return gulp.src('src/pages/**/*.jsx')
    .pipe(render({
      template:
        '<!doctype html>' +
        '<html><head><title><%=title%></title></head>' +
        '<body><%=body%></body></html>',
      harmony: false,
      data: {title: 'Page Title'}
    }))
    .pipe(gulp.dest('build'));
});

React Component Sample (src/pages/SomePage.jsx)

var React = require('react');
var DefaultLayout = require('../layouts/DefaultLayout.jsx');

var SomePage = React.createClass({
  statics: {
    layout: DefaultLayout
  },
  render() {
    return (
      <div className="container">
        <h1>React Component Sample</h1>
        <p>Lorem ipsum dolor sit amet.</p>
      </div>
    );
  }
});

module.exports = SomePage;

API

render(options)

optionvaluesdefault
templateLo-Dash template string or filenamenull
harmonytrue: enable ES6 featurestrue
stripTypestrue: enable Flow type annotationstrue
hyphenatetrue: SomePage.jsx -> some-page.htmltrue
staticMarkuptrue: HTML output will not have data-react-* attributesfalse
dataE.g. {title: 'Hello'} or function(file) { ... }object or function

Related Projects

React.js Starter Kit - a skeleton for an isomorphic web application (SPA)

License

The MIT License (MIT) @ Konstantin Tarkus (@koistya)

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago