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

jadelet-et

v0.8.0-pre.11

Published

Lightweight, elegant HTML templates

Downloads

4

Readme

Build Status

Jadelet

Pure and simple clientside templates

Jadelet is the cleanest and simplest way to describe your templates. It is a breeze to learn. Jadelet attributes correspond directly with HTML attributes. If you know HTML then you already know Jadelet.

Other libraries and frameworks put up barriers between you and the DOM. Like a dutiful servant, Jadelet brings the power of the DOM into your hands.

Jadelet is the smallest of all clientside templating libraries (< 2.5kb). But don't let its size fool you: it contains tremendous power.

Jadelet is free, MIT licensed, open source, non-GMO, and production ready.

Jadelet Hello

Examples

Header

h1= @title
HeaderTemplate = require "./header"
headerElement = HeaderTemplate
  title: "Hello world"

Button

button(click=@sayHey)
ButtonTemplate = require "./button"
buttonElement = ButtonTemplate
  sayHey: ->
    alert "heyy"

See more in the Example Playground

Getting Started

Install Jadelet:

npm install jadelet

Compile your templates:

node_modules/.bin/jadelet -d templates

This will create a .js version of each template in your templates directory.

To use the templates in a Node.js style project built with browserify you can require them normally.

// main.js
mainTemplate = require("./templates/main");

document.body.appendChild(mainTemplate(data));

Now use browserify to build the file you'll serve on your page.

browserify main.js > build.js

Road to 1.0

  • [x] Still under 2.5kb
  • [x] Don't Leak Resources
  • [x] Style Attributes
  • [x] Filters
  • [x] Changelog
  • [x] Example Playground
  • [x] | for text content
  • [x] Remove :filters
  • [x] Updated README.md
  • [ ] jadelet.com
  • [ ] Documentation
  • [ ] Getting Started Guide

FAQ

Ewww... CoffeeScript

That's not a question.

Is Jadelet safe from XSS?

Yes. Jadelet uses native DOM APIs to write string output as text nodes.

How do I use Jadelet to render HTML Elements?

Jadelet knows the type of objects it renders. When you pass an HTMLElement it will insert it into the DOM.

.content
  h1 My Canvas
  = @canvas
Template
  canvas: document.createElement('canvas')

Is it production ready?

Yes, we're currently using Jadelet to power glitch.com. (Though we still have a 'Beta' sticker up... ¯\_(ツ)_/¯)

Is it performant?

Yes! And because it's just DOM stuff you can easily drop down to the native DOM APIs for the pieces of your app that need special optimization.

How can I contribute?

Open some issues, open some pull requests, let's talk it out :)

History

Jadelet was inspired by Haml and Jade.

Gotchas

Templates must have only one root element, they will fail with multiple.

Good:

.root
  .one
  .two

Oopsies:

.one
.two

CLI

Command line interface for compiling templates.

Usage

Jadelet in, JavaScript out.

jadelet < template.jadelet > output.js

echo "h1#title= @title" | jadelet

Options

-d, --directory [directory] Compile all .jadelet files in the given directory.

jadelet -d templates

--encoding [encoding] Encoding of files being read from --directory (default 'utf-8')

--exports, -e [name] Export compiled template as (default 'module.exports')

--extension [ext] Extension to compile when compiling files from a directory. Default is jade(let)? so it should pick up both .jade and .jadelet files.

--runtime, -r [runtime_name] Specifies the name of the globally available Jadelet runtime (default is 'require("jadelet")').

jadelet -r "Jadelet" < template.jadelet > output.js

--ast, -a Output a JSON AST instead of the JavaScript template function. Useful for debugging or for using the Jadelet DSL as a frontend for other renderer backends like Mithril or React. Until 1.0 this isn't guaranteed to be a stable format.