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

utemplate

v2.2.5

Published

Templates are supported by default in HTML5, this is a single lightweight script to prepare them for you.

Downloads

52

Readme

µtemplate

Currently available on github and npm

NPM

Templates are supported by default in HTML5, this is a single lightweight script to prepare them for you.

  1. Create your template, it won't be rendered
  2. Decide where it belongs
  3. Prepare the template with some data
  4. Insert the prepared template into the DOM

install

npm

npm i --save utemplate

git

git clone [email protected]:Announcement/utemplate.git

usage

head

It doesn't have to be in the head, put it wherever you want, just make sure it's loaded before the script is run. We chose this location because if you don't have a <head> and <body> tags, most parsers throw the <template> in there by default.

<template id="message">
  <article>
    <h2>{title}</h2>
    <p>{message}</p>
  </article>
</template>

body

This is where we're going to put it for all to see

<section id="messages">
</section>

script

First, let's generate a new Template from our previously defined element.

Note that this can use the following provided by Alchemist

template = new Template("#message");

Next, we need to provide some data.

template.pipe({
  title: 'Hello, world!',
  message: 'How are you today?'
});

And decide what to do with it.

// attach it to the DOM (now via a querySelector)
template.pipe('#messages');

frequently asked questions

That's nice, but why is it useful?

In the real world, data is going to be from a source. My environment has a couchdb document, but yours can be whatever you want it to be

  • avoid writing html inside of javascript
  • don't document.createElement or document.createTextNode by hand
  • no more writing stringified json to the document.

Where does my data come from?

The properties directly correspond to the text inside of the template and are automatically filled with those keys.

As of version [email protected] they can be multiple levels deep such as {a: {b: {c: 'd'}}} and the template requests {a.b.c}

Why wouldn't I use Angular, Meteor, or something better

If you enjoy reading and learning new things, then those will probably better for you. But if you want something small, fast and want it to just work, then microTemplates are for you.

Ours is very small and easy to learn, so if you're a beginner (or a minimalist like myself), then you should definately start here.