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

tagster

v1.1.2

Published

Tagster is simple library which is helping you create html strings with ease.

Downloads

7

Readme

Tagster

Build Status

Tagster is simple library which is helping you create html strings with ease.

It works in both node and client-side applications.

Elements

Add slash to the end of element name to create element without closing tag.

var div = new Tagster().element;
// <div></div>

var header = new Tagster('header.header', { role: 'header' }).element;
// <header role="header" class="header"</header>

var header = new Tagster('#unique').element;
// <div id="unique"></div>

var image = new Tagster('img/', { src: 'img/partizan.png', alt: 'Volim Partizan!' }).element;
// <img src="img/partizan.png" alt="Volim Partizan!">

var custom = new Tagster('polymer-ajax', { url: 'http://example.com/json', handleAs: 'json' }).element;
// <polymer-ajax url="http://example.com/json" handleAs="json"></polymer-ajax>

Populate

You can populate element on two ways. First is passing by a string as third param when creating new element.

var header = new Tagster('header', { role: 'header' }, 'I am a header!').element;
// <header role="header">I am a header!</header>

Second way is to chain populateWith method which accepts function or string.

var header = new Tagster('header', { role: 'header' }).populateWith('I am a header!').element;
// <header role="header">I am a header!</header>

var header = new Tagster('header', { role: 'header' }).populateWith(function () {
    return new Tagster('a.logo', { href: '/' }, 'NameOfCompany').element;
}).element;

// <header role="header"><a class="logo">NameOfCompany</a></header>

Helpers

var jquery = new Tagster().script('js/vendor/jquery.js').element;
// <script src="js/vendor/jquery.js"></script>
var style = new Tagster().style('css/style.css').element;
// <link rel="stylesheet" href="css/style.css">

Extensible

Tagster is extensible, so you can create your helpers and methods.

Tagster.prototype.form = function (attrs) {
    this.attrs = attrs;
    this.el = 'form';
    this.createAttributes();
    this.createClosingElement();
    return this;
};

var form = new Tagster().form({ name: 'form', method: 'POST' }).element;
// <form name="form" method="POST"></form>

Tagster.prototype.meta = function (attrs) {
    this.attrs = attrs;
    this.el = 'meta';
    this.createAttributes();
    this.createElement();
    return this;
};

var viewport = new Tagster().meta({ name: 'viewport', content: 'width=device-width' }).element;
// <meta name="viewport" content="width=device-width">

Example

var menu = ['home', 'about', 'portfolio', 'contact'];

var nav = new Tagster('nav.nav', { role: 'navigation' }).populateWith(function () {
    return new Tagster('ul').populateWith(function () {
        var lis = [];

        menu.forEach(function (item) {
            lis.push(new Tagster('li.menu-item').populateWith(function () {
                return new Tagster('a', { href: '/#' + item }, item).element;
            }).element);
        });

        return lis.join("");
    }).element;
}).element;

/*

<nav role="navigation" class="nav">
    <ul>
        <li class="menu-item"><a href="/#home">home</a></li>
        <li class="menu-item"><a href="/#about">about</a></li>
        <li class="menu-item"><a href="/#portfolio">portfolio</a></li>
        <li class="menu-item"><a href="/#contact">contact</a></li>
    </ul>
</nav>

*/