• Stars
    star
    378
  • Rank 113,272 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pure and simple clientside templates

Build Coverage 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 (< 5.8kb). But don't let its size fool you: it contains tremendous power.

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

Examples

Header

h1 @title
const HeaderTemplate = require("./header")
const headerElement = HeaderTemplate({
  title: "Hello world"
})

Button

button(@click) Say Hey
ButtonTemplate = require("./button")
buttonElement = ButtonTemplate({
  click: function() {
    alert("heyy")
  }
})

More examples

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.

Require your templates normally and let webpack or whatever other godforsaken bundler you use do its magic.

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

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

Road to 1.0

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

FAQ

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 (or any other descendent of window.Node) it will insert it into the DOM as is.

.content
  h1 My Canvas
    @canvasElement
Template({
  canvasElement: document.createElement('canvas')
})

Is it production ready?

Yes, Jadelet's been used for years in production by glitch.com, whimsy.space, and danielx.net.

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. I kept removing features over the years until it was fast and simple enough for my tastes.

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")

When used with -d you can use $file to take on the stringified name of the current file. For example:

jadelet -d templates/ -e 'T[$file]'

The files will export as:

T["folder/subfolder/file"] = require('jadelet').exec(...)

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

If you are using jadelet-brower.js you'll want to replace this with 'Jadelet' so it can use the global in the browser.

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

More Repositories

1

pixel-editor

It edits pixels
CoffeeScript
134
star
2

Boomstick

Cross-browser multiplatform JavaScript joystick Input.
C++
42
star
3

matrix.js

Where Matrices become heroes together
JavaScript
31
star
4

pixieengine.com

Where pixels become heros, together.
Ruby
30
star
5

coffee-time

Set up casual weekly meetings between random people in your organization.
Ruby
29
star
6

priority_queue

A JavaScript PriorityQueue
CoffeeScript
29
star
7

zine

DIY E-Zine and Operating System
CoffeeScript
26
star
8

pixie

A JavaScript Pixel Editor
JavaScript
21
star
9

editor

Edit Github repos and run them in your browser.
CoffeeScript
17
star
10

composer

Compose music on the internets?
CoffeeScript
12
star
11

chlorian

Chlorian MIDI Player
JavaScript
10
star
12

hamlet-compiler

A formalized grammar for Haml
HTML
9
star
13

PixieEngine

This magical engine makes all of your wildest dreams come true
JavaScript
9
star
14

stream

Learning about streams
CoffeeScript
5
star
15

glitch.com

My staging fork of glitch.com
CoffeeScript
4
star
16

GreasyThug

Chrome Extension that provides jQuery console with history and saving scripts to autorun each time you visit web pages.
JavaScript
4
star
17

strd6.github.io

Github pages
4
star
18

jqcolor

Port of jscolor into a jQuery Plugin
JavaScript
4
star
19

Milky-Tracker

Just a mirror of Milky Tracker on github... for now
C++
4
star
20

NoJS

The smallest JS Framework
4
star
21

contrasaur.us

Contrasaurus HTML5 Game
JavaScript
4
star
22

qwello

Testing Civet + Qwik
TypeScript
3
star
23

PixieEngine-XNA

An XNA Game Studio runtime of PixieEngine
JavaScript
3
star
24

whimsy-rpg

Collaborative RPG game and editor.
JavaScript
3
star
25

pixie2

Updating PixieEngine, good luck!
CSS
3
star
26

cardprinter

JavaScript
3
star
27

tiny-game

Tiny Game Engine
CoffeeScript
3
star
28

s3_policy

Generate a signed S3 policy document for namespaced clientside uploads.
Ruby
3
star
29

Dangerous-To-Go-Alone

2
star
30

hyperweb

Prototyping some hypercard-ish ideas.
JavaScript
2
star
31

surfn

As a lone FBI agent you must surf to survive.
CoffeeScript
2
star
32

chateau

Real time avatar chat rooms
CoffeeScript
2
star
33

ld22

JavaScript
2
star
34

dropbox2s3

Sync Dropbox to S3
Ruby
2
star
35

torgo

Command line torrent scraper
Ruby
2
star
36

Chrome-Launcher

JavaScript
2
star
37

underscore-source

Ruby
2
star
38

redicegame.com

The website for the game Red Ice
Ruby
2
star
39

tempest

Templating that doesn't blow.
CoffeeScript
2
star
40

OIS

Bringing OIS to github
C++
2
star
41

Dirt-Farm

Dig some holes, plant some crops, and turn this dirt farm around!
2
star
42

space_demo

A simple demo for an HTML5 space shooter
JavaScript
2
star
43

puppetry

Servers and whatnot
Shell
2
star
44

PixieGraphs

Integrating Highcharts into pixie
2
star
45

Shoot-Them-Up

bbg game compo game
JavaScript
2
star
46

hamlet-runtime

Runtime environment for Hamlet
CoffeeScript
2
star
47

extralib

All those extras and experimental things that are too intense for gamelib
JavaScript
2
star
48

Space-Shooter-Demo

JavaScript
2
star
49

greasythug.net

It's like userscripts.org for greasy thugs.
Ruby
2
star
50

testin2

2
star
51

browserlib

JavaScript fills specific to game programming in the browser environment
JavaScript
2
star
52

Blastoids

Blast
2
star
53

tactics

Squad based HTML5 tactics game.
CSS
2
star
54

XNA-Shiv

Stabbing your way to XNA
JavaScript
2
star
55

FunctioSheet

A magical spreadsheet beyond your wildest dreams.
2
star
56

burosu

The legend of bros
JavaScript
2
star
57

jquery-source

Ruby
2
star
58

ironworks

Messing with iron.io
Ruby
2
star
59

ld33

Ludum Dare 33: You are the monster
CoffeeScript
2
star
60

microduel

An epic duel cardgame
Ruby
2
star
61

WebGL-Test

2
star
62

whimsy.space

A space of whimsy
Ruby
2
star
63

crash

CRAzy SHell
CoffeeScript
2
star
64

coffee-service

CoffeeScript compiler as a service that you can host wherevs
CoffeeScript
1
star
65

test3

CoffeeScript
1
star
66

s3clip

Copy images to S3
CoffeeScript
1
star
67

photoshack

Do stuff with images
CoffeeScript
1
star
68

athletic-support

Support for your node.
CoffeeScript
1
star
69

traffic_cone

Turn your iPad into a makeshift traffic cone in case of roadside emergency!
Ruby
1
star
70

trash-robots

LD27
JavaScript
1
star
71

laserhog

Lasers destroy your enemies
JavaScript
1
star
72

cloudy

Automating AWS stuff using fog
Ruby
1
star
73

ld26

A game where magical bubble make your wildest dreams come true
CoffeeScript
1
star
74

pixie-lite

JavaScript
1
star
75

futilibird

Flap, or not, it doesn't really matter.
CoffeeScript
1
star
76

spritepile

Edit a pile of sprites.
JavaScript
1
star
77

rooms

Simple Room Based HTML Editor
CoffeeScript
1
star
78

filesystem

Chrome Filesystem API
CoffeeScript
1
star
79

filetree

A simple filetree
CoffeeScript
1
star
80

ui

Classic User Interface
CoffeeScript
1
star
81

stalker

Follow people with common interests
Ruby
1
star
82

faze

Trying out Phaser.io
CoffeeScript
1
star
83

bttd

Experimental game in TinyGameEngine
CoffeeScript
1
star
84

series

Draw a series of data
CSS
1
star
85

os_client

OS system call client API for use in web workers
CoffeeScript
1
star
86

datagester

Information in, information out.
Ruby
1
star
87

learn_go

Learning golang
Go
1
star
88

learn_haskell

Learning me a Haskell
Haskell
1
star
89

grapplemeister

JavaScript
1
star
90

hello-world

Hello World
CoffeeScript
1
star
91

sound-recorder

Record sounds
JavaScript
1
star
92

notepad

Recreating the classics
CoffeeScript
1
star
93

webtube

How simple can webhooks be?
CoffeeScript
1
star
94

addressable

Using Amazon S3 as a content addressable store
Ruby
1
star
95

4lokos

Getting Loko with Heroku
Ruby
1
star
96

oisc

CoffeeScript
1
star
97

chat

Testing Meteor as a chat app
JavaScript
1
star
98

geotown

1
star
99

payments

Stripe pay what you want payments backend
Ruby
1
star
100

grappl3r

The third installment of the Grapple Man saga.
CoffeeScript
1
star