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

wge

v0.0.5

Published

A very cool node HTML templating engine.

Downloads

13

Readme

Wagon Engine

Wagon is a very fast and cool templating engine for fast development.

Here is quick example on the syntax.

<div id="myDiv">
    {#if (usingWagon === true)}
        {niceMessage()}
    {:else}
        Use it because it is cool.
    {/if}
</div>

As you can see, it is literally javascript in html.

Now lets try to compile this template.

let renderer = Template.fromFile("fullPathToTemplate.html").compile();
console.log(
  renderer({
    usingWagon: true,
    niceMessage: () => "Yay, you are using Wagon!",
  })
);

Ouputs

<div id="myDiv">Yay, you are using Wagon!</div>

Time to spice things up!

with for loops...

{#for (let i = 0; i < 10; i ++>)}
    {i}
{/for}

Outputs...

0 1 2 3 4 5 6 7 8 9

with while loops...

{#while (true)}
    Oops no good
{/while}

Outputs...

Nothing just like any javascript never ending loop.

with literally javascript code...

{%
    class Human {
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }
        greet() {
            return `Hello, my name is ${this.name} and I am ${this.age}.`
        }
    }
}
{new Human("Bob", 20).greet()}

Outputs...

Hello, my name is Bob and I am 20

Very simple syntax...

| syntax | description | example | | --------------------- | ----------------------------- | ------------------------------------ | | {code} | Evaluated and displayed | {"You will see me"} | | {% code} | Evaluated, but not displayed | {% let m = "You will not"} | | {# block statement} | Open a block statement | {# if (true)} | | {: block statement} | Chains a block statement | {: else if (true)} | | {/...} | Closes a block statement | {/ if} | | {@ code} | Evaluated during compile time | {@ this.include("./partial.html")} |

Render time variables

| name | description | | ------- | ------------------------------ | | $main | Root template name (full path) | | $html | In generation HTML | | $code | Generated code | | data | Props passed from the renderer |

$html can be modified by the template.

So...

{% $html += "Hello world"}

will be the same as...

{"Hello world"}

or even simpler...

Hello world

Compile time variables and methods

| name | description | | ------------------------------------- | ------------------------------------------- | | this.main | Root template name (full path) | | this.name | Current template name (full path) | | this.raw | Raw template | | this.code | In genration code | | this.vars | Render time variable names. eg. $html | | this.define(string name, any value) | Define a constant | | this.include(string relativePath) | Inserts compiled code from another template | | this.add(string code) | Inserts code during compile time |

Syntax highlighting

There is syntax highlighter in the VScode Marketplace. https://marketplace.visualstudio.com/items?itemName=str1z.html-wagon-syntax-highlighting