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

nephrite

v2.3.2

Published

[![Build Status](https://secure.travis-ci.org/Nami-Doc/nephrite.png)](http://travis-ci.org/Nami-Doc/nephrite)

Downloads

8

Readme

Nephrite

Pre-compiles jade to Coffee/Coco/LiveScript, allowing you to have the syntax of jade with the best perfs (only interpolation is used). It also avoids you the pain of undefined and null by auto-soaking.

To make you understand this a bit better, let's say that your code :

ul#pages
  for page in @pages
    li: a(href="page/#{page}")= page

will get compiled to

'<ul id="pages">' + join((function () {
  var ref$, results$ = [];
  for (key in ref$ = locals.pages) {
    val = ref$[key];
    results$.push('<li><a href="page/' + page + '">' + page + '</a></li>');
  }
  return results$;
}()) || '') + '</ul>'

Jade itself can be slow due to several factors (with, attrs, escape) and this project allows you to avoid that!

(the code is highly unstable and total crap) Tho, it's used in html5chan and wowboardhelpers.

Usage

Compile it and use it later. Attributes are passed as locals, aliased to @. You can pass an extra attributes object as @@

# compile it
nephrite = require 'nephrite'
src = nephrite.compile 'a(b="#{@c}")', 'index.jade'
js = Coco.compile src, {bare: true, filename}
# use it
fn obj, extra

Syntax

The syntax is the same as Jade, with a few gotchas :

  • Don't prefix your tags with -. - is jade interpolation, to allow for even better perfs on static content :
ul#pages
 - for (var i = 0; i <= 10; ++i)
   li(page=i)== i
  • The jade output is ==. This will be optimized (compiled by jade)

  • Tags are automatically recognized. Currently supported tags are : if, unless, while, for, else. Loops are automatically joined.

  • To avoid complexity in the converter, for attribute interpolation you have to explicitely interpolate them : a(href=foo) Foo! will use jade a(href="#{foo}") Foo! will use

  • The "silent code interpolation" is ~ (take note that any code interpolation appearing BEFORE content will be moved out of the closure for better perfs.) For example :

~ template = require 'user-template'
~ /*^ this will be moved out of the closure function*/
#users
  ~ /*this will not*/
  ~ "this won't be outputted anyway"