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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mini-render

v1.0.3

Published

### 开始 - 安装 ```bash npm install mini-render --save // 或者 <script src='miniRender.js'></script> ```

Readme

一个轻量的模板引擎

开始

  • 安装
npm install mini-render --save
// 或者
<script src='miniRender.js'></script>
  • 定义一些数据
<div id="box">...</div>
var data = {
    gt: 7,
    lt: 6,
    first: 'first',
    array: [1,2,3],
    object: {
         key1: 'value1',
        key2: 'value2'
    },
    word: 'aaaaa',
    empty: undefined
}
// 渲染元素模板
miniRender.renderElement('#box', data)

// 也可以返回渲染结果
var str = miniRender.renderString('<div>{{word}}</div>', data)
console.log(str)

渲染

<p>{{ first }}</p>
<!--结果:
    <p>first</p>
-->
  • 支持三元运算
<p>{{ gt > 8 ? gt : 8 }}</p>
<!--结果:
    <p>8</p>
-->

过滤

<p>{{ word | toUpperCase }}</p>
<!--结果: 
    <p>AAAAA</p>
-->

<script>
// 注册过滤器
miniRender.filter('toUpperCase', function(val){
    return val.toUpperCase()
})
// 移除过滤器
miniRender.removeFilter('toUpperCase')
</script>

过滤器仅可用在上边这种普通的取值中

判断

{{IF gt > lt}}
    <p>gt比较大:{{gt}}</p>
{{ELSEIF lt < gt}}
    <p>lt比较小:{{lt}}</p>
{{ELSE}}
    <p>都不成立</p>
{{/IF}}
<!--结果:
    <p>gt比较大:7</p>
-->

循环

<!--数组-->
{{EACH item, index IN array}}
    <p>索引:{{index}}  值:{{item}}</p>
{{/EACH}}
<!--结果:
    <p>索引:0  值:1</p>
    <p>索引:1  值:2</p>
    <p>索引:2  值:3</p>
-->

<!--对象-->
{{EACH val,key IN object}}
    <p>属性名:{{key}}  属性值:{{val}}</p>
{{/EACH}}
<!--结果:
    <p>属性名:key1  属性值:value1</p>
    <p>属性名:key2  属性值:value2</p>
-->