npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-wrap

v0.15.0

Published

A gulp plugin to wrap the stream contents with a template.

Downloads

93,958

Readme

gulp-wrap

NPM version Build Status Coverage Status Dependency Status devDependency Status

A gulp plugin to wrap the stream contents with a lodash template.

Usage

First, install gulp-wrap as a development dependency:

npm install --save-dev gulp-wrap

Then, add it to your gulpfile.js:

Wrap the contents with an inline template:

var wrap = require("gulp-wrap");

gulp.src("./src/*.json")
    .pipe(wrap('angular.module(\'text\', []).value(<%= contents %>);', {}, { parse: false /* do not parse the JSON file for template data */ }))
    .pipe(gulp.dest("./dist"));

Wrap the contents with a template from file:

var wrap = require("gulp-wrap");

gulp.src("./src/*.json")
    .pipe(wrap({ src: 'path/to/template.txt'}))
    .pipe(gulp.dest("./dist"));

Use parsed contents within a template (supports JSON and YAML):

var wrap = require("gulp-wrap");

gulp.src("./src/*.json")
    .pipe(wrap('Hello, <%= contents.title %>, have a <%= contents.adjective %> day.'))
    .pipe(gulp.dest("./dist"));

Provide additional data and options for template processing:

var wrap = require("gulp-wrap");

gulp.src("./src/*.json")
    .pipe(wrap('BEFORE <%= data.contents %> <%= data.someVar %> AFTER', { someVar: 'someVal'}, { variable: 'data' }))
    .pipe(gulp.dest("./dist"));

This gulp plugin wraps the stream contents in a template. If you want the stream contents to be the templates use the gulp-template plugin.

Template

The stream contents will be available in the template using the contents key. If the file extension is json, yaml, or yml then the contents will be parsed before being passed to the template. Properties from the vinyl file will be available in the template under the file object and are local to that stream. User supplied data values will always take precedence over namespace clashes with the file properties.

API

wrap(template[,data][,options])

template

Type: String or Object or Function

The template to used. When a String then it will be used as the template. When an Object then the template will be loaded from file. When a Function then the function will be called and should return the template content. This function get the data object as first parameter.

template.src

Type: String

The file location of the template.

data

Type: Object or Function

The data object that is passed on to the lodash template call. When a Function then the function will be called and should return the Object data used in the template.

options

Type: Object or Function

The options object that is passed on to the lodash template call. When a Function then the function will be called and should return the Object used as the options.

options.parse

Type: Boolean

Set to explicit false value to disable automatic JSON and YAML parsing.

options.engine

Type: String

Set the consolidate template engine to use. (default to lodash). Using another engine that lodash may require installation of additional node package.

License

MIT License