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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gulp-micro-tpl-compiler

v0.0.7

Published

gulp plugin develop for mtpl compiler

Readme

gulp micro template编译器,将micro template提前预编译为function,提升模板性能。编译后的模板可通过配置支持seajs,requirejs,kissy,nodejs模块化,也可以完全自定义配置项wrap配置编译后代码的前后包裹。

特性

  • micro template直接使用js语法,近乎零学习成本
  • 通过编译micro template提升模板运行性能
  • 支持模板间互相调用
  • 因为使用js语法,支持同时运行在client(浏览器)端和server(nodejs)端
  • 支持模板编译报错提示错误信息,源模板行号
  • 支持模板运行错误时提示错误信息,源模板行号

使用

安装

npm install gulp-micro-tpl-compiler --save-dev

gulpfile.js

require('gulp-micro-tpl-compiler');

样例

gulp.task('compiler', function() {
    gulp.src('./src/**/*.mtpl.html')
        .pipe(plumber())
        .pipe(mtpl(
            {
                wrap: 'kissy'
            }
        ))
        .pipe(rename(function(path) {
            console.log(path.basename);
            path.extname = '.js';
        }))
        .pipe(gulp.dest('./build'))
});

参数说明

banner

类型: String

默认: ''

文件头。

lineNumber

类型: Boolean

默认: false

运行错误时是否提示行号,默认不提示。

wrap

类型: String|Object|function

可选: 'nodejs', 'requirejs', 'seajs', 'kissy', wormhole, 'default', {before: '', after: ''} or

function(code) {
    //do something
    return code;
}

Default: default

/**
 * options.wrap {Object}
 */
wrap {
    before: 'KISSY.add(function (S, require, exports, module) {\n module.exports = ',
    after: '});'
}

对代码进行封装,可以使用现有模板 'requirejs', 'nodejs', 'kissy'等等

鸣谢

grunt-micro-tpl-compiler项目。