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

@jakub21/shp

v1.0.0

Published

This is a Javascript port of my HTML preprocessor that's to be used on the client side. It can be used to dynamically create complex DOM fragments, using SHP syntax.

Downloads

1

Readme

SHP.js

This is a Javascript port of my HTML preprocessor that's to be used on the client side. It can be used to dynamically create complex DOM fragments, using SHP syntax.

For more information about SHP syntax check the SHP.py repository.

See ./demo for a functional example.

Package setup

Node setup

  1. Install from the NPM npm install @jakub21/shp
  2. Require the package to get the path to the bundled file require('@jakub21/shp').path
  3. Use your server setup to serve the file
  4. Add a <script> tag in your HTML document with your chosen path

No Node setup

If you do not use Node.js you can download prebuilt shp.js file from the releases tab. Add a <script> tag that points to this file instead.

Usage with Domi.js

The best way to use this package is through Domi.js.

See this section of readme for relevant information.

Standalone usage

The whole package is contained within a global shp object. You can use the compiler yourself for more control or utilize aliases for ease and code clarity.

Aliases

append(element, shp)

Compiles shp and appends created nodes to element.

shp.append(document.body, `
  $div[#Footer] {
    Footer content
  }
`);

prepend(element, shp)

Compiles shp and prepends created nodes to element.

shp.append(document.body, `
  $div[#Header] {
    Header content
  }
`);

Compiler

const compiler = new shp.Compiler();

Used to compile SHP code.

compile(shp)

Returns an array of DOM nodes.

var nodesArr = compiler.compile(`
  $div[#Content] {
    Hello world!
  }
`);

reset()

Resets internal state. Must be used between compile calls.

nodesArr = compiler.compile('$p[.red] { Line 1 } ');
compiler.reset();
nodesArr = compiler.compile('$p[.blue] { Line 2 } ');