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

shaven

v2.1.0

Published

Shaven is a simple DOM building utility and template engine based on JsonML

Downloads

6,997

Readme

Logo

Shaven

Build Status

A DOM building utility and Template engine based on JsonML with syntax sugar.

Checkout shaven.ad-si.com for extensive documentation.

Example

shaven(
  [document.body,
    ['h1#logo', 'Static Example'],
    ['p','Some example text'],
    ['ul#list.bullets',
      ['li', 'item1'],
      ['li.active', 'item2'],
      ['li',
        ['a', 'item3', {href: '#'}]
      ]
    ],
    ['em', 'Important', {
      style: {
        color: 'red',
        'font-size': '2em',
      },
    }]
  ]
)

compiles to

<body>
  <h1 id="logo">Static Example</h1>
  <p>Some example text</p>
  <ul id="list" class="bullets">
    <li>item1</li>
    <li class="active">item2</li>
    <li><a href="#">item3</a></li>
  </ul>
  <em style="color:red;font-size:2em">Important</em>
</body>

In order to convert HTML fragments to shaven arrays html2shaven can be used.

Features

  • Syntax Sugar for ids, classes and variable caching
  • Support for namespaces. (Lets you build SVGs and other XML based languages)
  • Callback functions on elements
  • Returns a Object containing the root element and the elements with an id

Advantages

  • Leverage the full power of JavaScript in your templates. => No need to learn a new language!
  • Directly integrable into JavaScript files
  • Works in front- and backend environment
  • Templates normally tend to get more complicated with the number of variables as they need to get escaped in some way. With Shaven it's exactly the opposite. As variables are native to Shaven the templates get simpler with an increasing number of variables.
  • Shaven templates can be easily build with every major programming language and their existing JSON/YAML tools.

Installation

npm install --save shaven

Check out shaven.ad-si.com for a detailed description of how to install shaven in other environments.

Browser Support

  • Firefox: 20+
  • Opera: 21+
  • Chrome: 34+
  • Safari: 9+ (Does not correctly escape HTML strings in attributes)
  • IE: ? (Probably 9+. Please submit a pull request if you know more.)
  • Edge (EdgeHTML): 12+

Earlier Firefox, Opera and Chrome versions have the same bug as Safari. That means even much older versions will just work fine under normal circumstances.

Development

Check if code changes must be made in the server and browser version of shaven.

  • Build website make
  • Bump version
    1. Change version number in package file (semver)
    2. Execute npm run prepublish
    3. Commit
    4. Tag commit (v<version>)
  • Publish to npm npm publish
  • Release new version of website: make deploy