| CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Mon, 22 Dec 2025 09:15:39 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100103042511
location: https://web.archive.org/web/20100103042511/https://github.com/edspencer/jaml
server-timing: captures_list;dur=0.698426, exclusion.robots;dur=0.045591, exclusion.robots.policy;dur=0.033883, esindex;dur=0.009151, cdx.remote;dur=34.451664, LoadShardBlock;dur=285.017926, PetaboxLoader3.datanode;dur=71.055364, PetaboxLoader3.resolve;dur=39.035171
x-app-server: wwwb-app225-dc8
x-ts: 302
x-tr: 371
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app225; path=/
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Mon, 22 Dec 2025 09:15:40 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Sun, 03 Jan 2010 04:25:11 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "95da4b85ce87eb5966a83cada539c902"
x-archive-orig-x-runtime: 147ms
x-archive-orig-content-length: 27305
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 03 Jan 2010 04:25:11 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: TLA-20100103040208-00131-ia360918-c/TLA-20100103042119-00143-ia360906.us.archive.org.warc.gz
server-timing: captures_list;dur=0.730987, exclusion.robots;dur=0.023378, exclusion.robots.policy;dur=0.010941, esindex;dur=0.013163, cdx.remote;dur=9.094739, LoadShardBlock;dur=159.670019, PetaboxLoader3.datanode;dur=122.344380, PetaboxLoader3.resolve;dur=110.947862, load_resource;dur=113.875982
x-app-server: wwwb-app225-dc8
x-ts: 200
x-tr: 347
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
edspencer's jaml at master - GitHub
edspencer / jaml
- Source
- Commits
- Network (10)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
-
Branches (2)
- gh-pages
- master ✓
- Tags (0)
jaml /
| name | age | message | |
|---|---|---|---|
| |
.DS_Store | Tue Oct 20 04:15:43 -0700 2009 | Initials [Ed Spencer] |
| |
.gitmodules | Tue Oct 20 04:15:43 -0700 2009 | Initials [Ed Spencer] |
| |
Jaml-all.js | Mon Nov 23 16:20:05 -0800 2009 | Removed Renderer in favour of Template. Removed... [edspencer] |
| |
Jaml.js | Mon Nov 23 16:20:05 -0800 2009 | Removed Renderer in favour of Template. Removed... [edspencer] |
| |
Node.js | Mon Nov 23 16:20:05 -0800 2009 | Removed Renderer in favour of Template. Removed... [edspencer] |
| |
README.textile | Tue Nov 03 17:31:25 -0800 2009 | Readme fixes [Ed Spencer] |
| |
Template.js | Mon Nov 23 16:20:05 -0800 2009 | Removed Renderer in favour of Template. Removed... [edspencer] |
| |
examples/ | Mon Nov 23 16:20:05 -0800 2009 | Removed Renderer in favour of Template. Removed... [edspencer] |
| |
specs/ | Tue Oct 20 04:15:43 -0700 2009 | Initials [Ed Spencer] |
README.textile
Jaml: beautiful HTML generation for JavaScript
Jaml tries to emulate Ruby’s Haml library, making it easy to generate HTML in your JavaScript projects.
Examples
Something Simple
Registering a template is easy:
Jaml.register('simple', function() { div( h1("Some title"), p("Some exciting paragraph text"), br(),ul( li("First item"), li("Second item"), li("Third item") ) ); });
So is rendering it:
Jaml.render('simple');
Here’s the output (yes, the indentation really is that pretty):
<div>
<h1>Some title</h1>
<p>Some exciting paragraph text</p>
<br />
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</div>
Templating
Usually we want to inject data into templates – let’s see how to do that:
Jaml.register('product', function(product) { div({cls: 'product'}, h1(product.title),p(product.description),img({src: product.thumbUrl}), a({href: product.imageUrl}, 'View larger image'),form( label({for: 'quantity'}, "Quantity"), input({type: 'text', name: 'quantity', id: 'quantity', value: 1}),input({type: 'submit', value: 'Add to Cart'}) ) ); });
And now to render it:
//this is the product we will be rendering var bsg = { title : 'Battlestar Galactica DVDs', thumbUrl : 'thumbnail.png', imageUrl : 'image.png', description: 'Best. Show. Evar.' };Jaml.render('product', bsg);
Which gives us:
<div class="product">
<h1>Battlestar Galactica DVDs</h1>
<p>Best. Show. Evar.</p>
<img src="thumbnail.png" />
<a href="image.png">View larger image</a>
<form>
<label for="quantity">Quantity</label>
<input type="text" name="quantity" id="quantity" value="1"></input>
<input type="submit" value="Add to Cart"></input>
</form>
</div>
Collections and partials
We can reuse templates inside other templates. Here we make a Category template to hold more than one product:
Jaml.register('category', function(category) { div({cls: 'category'}, h1(category.name), p(category.products.length + " products in this category:"),div({cls: 'products'}, Jaml.render('product', category.products) ) ); });
Now we render it with a couple of products:
//here's a second product var snowWhite = { title : 'Snow White', description: 'not so great actually', thumbUrl : 'thumbnail.png', imageUrl : 'image.png' };//and a category var category = { name : 'Doovde', products: [bsg, snowWhite] }Jaml.render('category', category);
Which gives us:
<div class="category">
<h1>Doovde</h1>
<p>2 products in this category:</p>
<div class="products"><div class="product">
<h1>Battlestar Galactica DVDs</h1>
<p>Best. Show. Evar.</p>
<img src="thumbnail.png" />
<a href="image.png">View larger image</a>
<form>
<label for="quantity">Quantity</label>
<input type="text" name="quantity" id="quantity" value="1"></input>
<input type="submit" value="Add to Cart"></input>
</form>
</div>
<div class="product">
<h1>Snow White</h1>
<p>not so great actually</p>
<img src="thumbnail.png" />
<a href="image.png">View larger image</a>
<form>
<label for="quantity">Quantity</label>
<input type="text" name="quantity" id="quantity" value="1"></input>
<input type="submit" value="Add to Cart"></input>
</form>
</div>
</div>
</div>
This feature is coming soon. Sit tight!
