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

saker

v1.1.1

Published

Saker is a template engine for Node.js and browsers, it is lightweight, powerfull and easy to use.

Downloads

15

Readme

Saker

Full documentation is at https://eshengsky.github.io/saker/.
完整文档请查看https://eshengsky.github.io/saker/

Saker is a template engine for Node.js and browsers, it is lightweight, powerfull and easy to use.
The greatest feature is, Saker minimizes the number of characters and keystrokes required in a file, and enables a fast, fluid coding workflow. Unlike most template syntaxes, you do not need to interrupt your coding to explicitly denote server blocks within your HTML. See Example for preview.
Saker是一个可以用于Node.js和浏览器端的模板引擎,轻量、强大、易于使用。其最大的特点是,尽可能地减少了模板文件中的额外字符和击键数,支持快速流畅的编码流程。不同于大多数的模板引擎语法,你无须打断你的编码来显式表明HTML中的服务器代码 —— Saker能够智能识别哪些是HTML哪些是服务器脚本。可以查看示例代码作为预览。

Build Status NPM version

Comparison 比较

Let's compare Saker with other hot template engines.
Saker和当前较流行的几款模板引擎(Jade、Handlebars、ejs)的比较。

Live Demo 在线演示

You can test drive Saker online here.
你可以在这里测试Saker。

Installation 安装

$ npm install saker

Example 示例

This is a very simple and representative sample, it shows a name list when code is 1, and if the gender is female, the <li> tag has a class 'pink'.
这是一个非常简单又很典型的例子,当code的值为1时会显示一个名单,如果gender字段是female,则<li>标签还会添加'pink'类。

data 数据

{
    "code" : 1,
    "data": [{
        "id" : 1,
        "name" : "Sky",
        "gender" : "male"
    }, {
        "id" : 2,
        "name" : "Kathy",
        "gender" : "female"
    }]
}

template 模板

@{ this.layout = null }

<h2>Name List</h2>
<article>
    @if(code === 1) {
        <ul>
            @{
                data.forEach(function(person) {
                    <li class="@(person.gender === 'female' ? 'pink' : '')">
                        <a href="/details/@person.id">@person.name</a>
                    </li>
                });
            }
        </ul>
    } else {
        <p>Sorry, no data!</p>
    }
</article>

result 结果

<h2>Name List</h2>
<article>
    <ul>
        <li>
            <a href="/details/1">Sky</a>
        </li>
        <li class="pink">
            <a href="/details/2">Kathy</a>
        </li>
    </ul>
</article>

For more examples, please see examples folder, it includes 3 examples each based on:
更多示例请查看examples目录,其包含了3个示例分别基于:

Syntax 语法

As you see above, Saker uses '@' as the default mark symbol (support custom) - the codes after it represent server-side scripts. The following is the syntax cheat sheet, for more details you can see Syntax Reference.
正如你在上面看到的,Saker使用'@'作为默认的标记符号(支持自定义)——在这之后的代码都视作是服务器端脚本。下面是一个语法速查,更详细的文档请查看Syntax Reference

Test 测试

You can execute the following script in terminal to run test.
你可以在终端执行下面的脚本来运行测试。

$ npm test

License 许可

The MIT License (MIT)

Copyright (c) 2016 Sky

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.