Socket
Socket
Sign inDemoInstall

gulp-react-templates

Package Overview
Dependencies
85
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

.eslintrc

76

index.js

@@ -1,41 +0,51 @@

var through = require("through2"),
gutil = require("gulp-util"),
fs = require("fs")
reactTemplates = require("react-templates");
'use strict';
// through2 is a thin wrapper around node transform streams
var through = require('through2');
var gutil = require('gulp-util');
var rt = require('react-templates');
var PluginError = gutil.PluginError;
var path = require('path');
var merge = require('merge');
module.exports = function (param) {
"use strict";
// Consts
var PLUGIN_NAME = 'gulp-react-templates';
function reactTemplatesPipe(file, enc, callback) {
/*jshint validthis:true*/
module.exports = function (opt) {
function replaceExtension(filePath) {
return filePath + '.js';
}
if (file.isNull()) {
this.push(file);
return callback();
}
function transform(file, enc, cb) {
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
}
if (file.isStream()) {
this.emit("error",
new gutil.PluginError("gulp-react-templates", "Stream content is not supported"));
return callback();
}
//console.log('rt ' + file.path);
if (file.isBuffer()) {
param = param || {};
param._ = [file.path];
var ret = reactTemplates.executeOptions(param);
if (ret) {
this.emit("error",
new gutil.PluginError("gulp-react-templates", "rt " + file.path + " failed"));
}
var data;
var str = file.contents.toString('utf8');
var dest = replaceExtension(file.path);
file.contents = new Buffer(fs.readFileSync(file.path + ".js"));
file.path = file.path + '.js';
var options = merge({
filename: file.path,
sourceFiles: [file.relative],
generatedFile: replaceExtension(file.relative)
}, opt);
this.push(file);
}
return callback();
}
try {
data = rt.convertTemplateToReact(str, options);
} catch (err) {
return cb(new PluginError(PLUGIN_NAME, err));
}
return through.obj(reactTemplatesPipe);
};
file.contents = new Buffer(data);
file.path = dest;
cb(null, file);
}
return through.obj(transform);
};
{
"name": "gulp-react-templates",
"version": "0.0.4",
"version": "0.0.5",
"description": "Gulp plugin for react-templates - Light weight templates for react -> write html get valid react code",
"repository": "wix/gulp-react-templates",
"main": "./index.js",
"keywords": [
"gulpplugin"
"gulpplugin",
"templates",
"react-templates",
"react",
"reactjs",
"react.js"
],
"author": {
"name": "Yoel Zeldes",
"email": "yoel.zeldes@gmail.com",
"url": "https://github.com/yoel-zeldes"
},
"repository": "yoel-zeldes/gulp-react-templates",
"scripts": {
"test": "istanbul test _mocha --report html -- test/*.js --reporter spec"
"test": "mocha"
},
"dependencies": {
"gulp-util": "~2.2.0",
"react-templates": "^0.1.7",
"through2": "*"
"gulp-util": "^3.0.0",
"merge": "^1.2.0",
"react-templates": "^0.1.8",
"through2": "^0.6.1"
},
"devDependencies": {
"mocha": "*",
"coveralls": "*",
"mocha-lcov-reporter": "*",
"istanbul": "*",
"event-stream": "*",
"should": "~2.1.0"
"mocha": "^2.0.0",
"should": "^4.0.4"
},

@@ -30,0 +28,0 @@ "engines": {

# gulp-react-templates
[![NPM version][npm-image]][npm-url]
> [react-templates](http://wix.github.io/react-templates) plugin for [gulp](https://github.com/wearefractal/gulp)
> Build react-templates
## Usage
## Installation
First, install `react-templates` and `gulp-react-templates` as a development dependency:
Install package with NPM and add it to your development dependencies:
```shell
npm install --save-dev react-templates gulp-react-templates
```
`npm install --save-dev gulp-react-templates`
Then, add it to your `gulpfile.js`:
## Usage
```javascript
var react-templates = require("gulp-react-templates");
var gulp = require('gulp');
var rt = require('gulp-react-templates');
gulp.src("./src/*.rt")
.pipe(react-templates({
modules: 'amd'
}))
.pipe(gulp.dest("./dist"));
gulp.task('rt', function() {
gulp.src('src/**/*.rt')
.pipe(rt({modules: 'amd'}))
.pipe(gulp.dest('src'));
});
```
## API
## Options
### react-templates(options)
The options `gulp-react-templates` can get are the same as `react-templates`'s options. Just type `rt --help` in your shell in order to learn about the available options.
- `modules`
Select modules system (amd|commonjs|none).
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
[npm-url]: https://npmjs.org/package/gulp-react-templates
[npm-image]: https://badge.fury.io/js/gulp-react-templates.png
See more [here](https://github.com/wix/react-templates/blob/gh-pages/docs/cli.md)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc