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

wTemplate

v1.0.3

Published

let data rander to page

Downloads

3

Readme

template

名称:前端模板引擎

作者:邬畏畏

功能:把JSON数据渲染到页面。 此模板实现的功能比较简单,希望大家多提建议。

页面HTML:

<div class="app-myapp fl ${bgcolor}">
    <div class="app-myapp-shared">${numbers.app.count}</div>
    <div class="app-myapp-photo icons"></div>
    <div class="app-myapp-caption">${title}</div>
    <div class="app-myapp-op">
        <a target="_blank" href="http://${url}">${url}</a>
    </div>
</div>

#代码示例一:

var data = [

    {
    	title:"我的应用1",
        url:"www.cnblogs.com/wsoft",
    	numbers:
    	{
    		app:{count:"100"}
    	}
    },
    {
    	title:"我的应用2",
        url:"www.xx.com",
        numbers:
        {
            app:{count:"500"}
        }
    },
    {
    	title:"我的应用3",
        url:"www.yy.com",
        numbers:
        {
            app:{count:"300"}
        }
    }

];

template.repeat({
    repeatId:".app-myapp",    //可以使用 repeatElement:$(".app-myapp")[0],
    data:data,
    count:3,
    type:"cover"         
    //可选择参数 type="cover" 覆盖; type="insert" 加载到现有数据前面; type="append" 加载到现有数据的后面
});

参数说明:

1.repeatId 是 模板DOM元素

repeatElement 是 模板DOM元素

2.data 是 array

3.count 是 读取的记录个数(参数可选)

4.type 是 数据载入的方式

#代码示例二:

template.repeat({
    repeatId:".app-myapp",
    data:data,
process:function(object){ //动态处理每个记录的某个字段
	return  {
                "bgcolor": object.index%2==0?"odd":"even" ,
                "title"  : "<i>"+object.item.title+"</i>" ,
                "numbers.app.count" : parseInt(Math.random()*100)
        };
}
});

参数说明:

process 是 data参数中每个对象的自定义处理函数,参数可选。

process 函数的参数参数object:

object 是 包含index和item

object.index 是 array中的索引

object.item 是 data数组里的每一行

    return {...}可以自定义页面的字段值
    
    功能: 
    
    元素 <div class="app-myapp fl ${bgcolor}"> 中的 ${bgcolor}被替换为 odd 或 even
    
    bgcolor,title,numbers.app.count就是页面上的${bgcolor},${title},${numbers.app.count}