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

jawa-juice

v0.3.0

Published

A small, CoffeeKup-like DOM-based templating language.

Downloads

6

Readme

Overview

jawa-juice is a small, CoffeeKup-like DOM-based templating language. Just for fun.

I made it primarily to learn about Proxy, which is the secret sauce to the whole thing. Since the browser support for Proxy is quite bad, it's not very usable. I've only tested it in Firefox. And since it is DOM based, you can't use it on Node.js either. Well, you could try to use some DOM module and patch document, or whatever. I just tried to create a nice DSL with small amounts of code.

Here is CoffeeKup's example translated to jawa-juice, just to give a little taste what it looks like.

module.exports = ({title, description, path, user, post})->
  @html ->
    @head ->
      @meta(charset: "UTF-8")
      @title "#{title or "Untitled"} | A completely plausible website"
      @meta(name: 'description', content: description) if description?

      @link(rel: "stylesheet", href: "/css/app.css")

      @style """
        body {font-family: sans-serif}
        header, nav, section, footer {display: block}
      """

      @script(src: "/js/jquery.js")

    @body ->
      @header ->
        @h1 title or 'Untitled'

        @nav ->
          @ul ->
            @li @a(href: "/") "Home" unless path is "/"
            @li @a(href: "/chunky") "Bacon!"
            @li switch user.role
              when "owner", "admin"
                @a(href: "/admin") "Secret Stuff"
              when 'vip'
                @a(href: "/vip") "Exclusive Stuff"
              else
                @a(href: "/commoners") "Just Stuff"

      @div.myclass.anotherclass(id: "myid", style: "position: fixed") ->
        @p "Divitis kills! Inline styling too."

      @section ->
        @breadcrumb = require("mixins/breadcrumb")
        @breadcrumb separator: ">", clickable: yes

        @h2 "Let's count to 10:"
        @p i for i in [1..10]

        form_to = (attributes, post, block) =>
          @form(attributes)(method: "post") block
        # another way ...
        form_to = (attributes, post, block) =>
          @form(attributes)(method: "post") ->
            @label
              @ "Date:"
              @input(type: "date")
            @ block

        form_to id: "to-form", post, ->
          @textbox(id: "title", label: "Title:")
          @textbox(id: "author", label: "Author:")
          @input(type: "submit") "Save"

      @footer ->
        @p "Bye!"

But remember that jawa-juice is DOM-based, so you probably won't generate a whole document like this with it. More likely just a little partial here and there.

Installation

npm install jawa-juice

Usage

render = require "jawa-juice"
template = require "templates/tatooine"

fragment = render template,
  user: "R2-D2"
  location: "Luke's Speeder"

document.body.appendChild(fragment)

Development

Tests

brunch is used for testing.

First run npm install to install dependencies.

Then run npm test to compile test files and fire up a server. Finally visit localhost:3333 in a browser.

The cool thing is that the tests will auto-reload as soon as you modify either the source code or the tests.

Language reference

First, have a look at the example above. That should get you going.

Then, have a look at the tests. They're straight-forward and self-documenting.

License

The X11 “MIT” License.