Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
/ gulp-js-string Public archive

A gulp plugin for exporting contents as string.

License

Notifications You must be signed in to change notification settings

bouzuya/gulp-js-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-js-string

A gulp plugin for exporting contents as string.

Installation

$ npm install --save-dev gulp-js-string

Usage

var jsString = require('gulp-js-string');

gulp.src('./views/*.bhtml')
    .pipe(jsString())
    .pipe(gulp.dest('./dist'));

Input: index.html:

<p>meow...meow...</p>

Output: index.js:

module.exports = '<p>meow...meow...</p>';

Configuration

Optionally, the format can be configured:

var jsString = require('gulp-js-string');

gulp.src('./views/*.bhtml')
    .pipe(jsString(function(escapedString, file) {
        var varname = file.basename.split('.')[0];
        return 'exports.' + varname + ' = \'' + escapedString + '\';';
    }))
    .pipe(gulp.dest('./dist'));

Input: index.html:

<p>meow...meow...</p>

Output: index.js:

exports.index = '<p>meow...meow...</p>';

This is espacially useful if used in combination with gulp-concat to merge several files.

License

MIT

Author

bouzuya <m@bouzuya.net> (http://bouzuya.net)

Contributors

About

A gulp plugin for exporting contents as string.

Resources

License

Stars

Watchers

Forks

Packages

No packages published