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

@hyjiacan/wet

v0.5.2

Published

Simple Server-end Web Template Engine based on NodeJS

Downloads

7

Readme

wet

wet: WEb Template

wet is a simple server-end WEB template engine based on ES6, with no 3rd-part dependency.

Features

t-for

Iterating array(for..of) and set(for..in): <t-for on="item of list" step="1">, item should be a valid identifier; step is a number to specify the step-length (takes effect on the array iterating only), default: 1

Also:

<t-for on="value, key in obj" />
<t-for on="item, index of arr" />
<t-for on="item, index of 1-10" />

When iterating an array:

1-10 means iterating from 1 to 10. 0-10 can be 10. Cannot put any whitespace besides -. FYI, integer supported only.

The boundary always included:

  • 1-10: 1, 2, ..., 9, 10
  • 0-10: 0, 1, ..., 9, 10
  • 10: 0, 1, ..., 9, 10
  • 9: 0, 1, ..., 9

t-if

Condition: <t-if on="condition">, condition can be an expression or variable

t-else

Condition: <t-else>

t-elif

Condition<t-elif on="condition">, condition can be an expression or variable

t-with

Make a scope <t-with varName="a.b.c">, varName equals the value of a.b.c, varName should be a valid identifier

t-tree

Render tree structure <t-tree on="tree as item">:

  • tree is a field of context, should b e an Array (in order to support for multiple root nodes)
  • item is the variable name in the scope

You should(must) use <t-children field="children" /> to specify where to render the children nodes.

t-html

Provide a method to render with the raw html: <t-html>{{'{{exp}}<p></p>{{exp}}'}}</t-html>.

t-include

Provide to import an external template file: <t-include file="./another.html" />

Attribute file specify where the template located, And should be a relative path (based on current template file path)

t-include can only contain t-fill as child

t-hole/t-fill

t-hole leave a hole in the template file, to fill it when another file includes it.

a.html

<div>
    <t-hole name="title">
      <div>default content</div>
    </t-hole>
    <t-hole></t-hole>
</div>

In the template file above, we got two holes. One with a name title:<t-hole name="title">,and another without a name: <t-hole>

No matter it has a name or not, hole name must be unique.

b.html

<t-include file="a.html">
  <t-fill>Fill anonymous hole</t-fill>
  <t-fill name="title">Fill named hole: title</t-fill>
</t-include>

No matter it has a name or not, fill name must be unique.

{{}}

Expression: {{var}}, {{obj.prop.value}}, {{a - b}}

The form {!{/}!} makes the raw {{/}} output: {{/}}.

Sample

demo.html

<div>
  <ul>
    <t-for on="item of list">
      <li>{{item}}</li>
    </t-for>
    <t-for on="item in set">
      <li>
        {{item.key}}: {{item.value}}
        <t-with xx="item.value.x.y">
          <span>{{xx.z}}</span>
        </t-with>
      </li>
    </t-for>
  </ul>
  <t-if on="visible">
    condition is true
  </t-if>
  <t-else>
    condition is false
  </t-else>
  <t-tree on="treeData as item">
    <div>
      {{item.data}}
      <div>
      	<t-children />    
      </div>
    </div>
  </t-tree>
  <t-include file="../common/footer.html" />
</div>
const context = {
  list: [1, 2, 3],
  set: {
    a: 1,
    b: {
      x: {
        y: {z: 5}
      }
    },
    c: 3
  },
  visible: false
}
wet.render('./demo.html', context, {cache: true})

context must be a Object, must not be an Array