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-template-compile-es6

v1.0.3

Published

Gulp task to precompile lodash templates into ES6 exported variables

Downloads

9

Readme

gulp-template-compile

Compile Lo-Dash templates (should work with Underscore templates too).

Synopsis

This plugin is heavily inspired by Emanuele Ingrosso.

I've written another plugin which only exports templates' string and can also wrap them with a compilation function

Install

Install with npm

npm i --save-dev gulp-template-compile-es6

Example

gulpfile.js

var gulp     = require('gulp');
var template = require('gulp-template-compile-es6');
var concat   = require('gulp-concat');

gulp.task('default', function () {
	gulp.src('src/*.html')
		.pipe(template({
            templateSettings : {
                variable : 'data'
            }
        })) // pass any settings here
		.pipe(concat('templates.js'))
		.pipe(gulp.dest('dist'));
});

Above will output the file templates.js:

(for 2 simple html files a.html & b.html which contains the string "foo" & "bar")

export var a = function(data) {
    var __t, __p = '';
    __p += 'foo';
    return __p;
}

export var b = function(data) {
    var __t, __p = '';
    __p += 'bar';
    return __p;
}

API

See the Lo-Dash _.template docs.

template(options)

options

Type: Object

options.name

Type: Function Default: Relative template path. Example: templates/list.html

You can override the default behavior by supplying a function which gets the current File object and is expected to return the name.

Example:

{
    name: function (file) {
        return 'tpl-' + file.relative;
    }
}

options.namespace

Type: String Default: 'JST'

The namespace in which the precompiled templates will be assigned. Starting from version 1.0 you could also provide a dotted namespace that will be correctly handled, thanks to fhawkes. For example 'custom.namespace' will result in window['custom']['namespace'].

options.templateSettings

Type: Object Default: null

Lo-Dash _.template options.

License

MIT © Yair Even-Or