npm: package manager

    gulp-js-string

    1.0.0 • Public • Published

    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

    Keywords

    Install

    npm i gulp-js-string

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • bouzuya