| CARVIEW |
Select Language
HTTP/2 200
server: nginx
date: Mon, 22 Dec 2025 17:15:44 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Thu, 03 Dec 2009 04:20:49 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "089b3f3ccdd9469d7215e5a2e6b75381"
x-archive-orig-x-runtime: 65ms
x-archive-orig-content-length: 29247
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: Thu, 03 Dec 2009 04:20:50 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: 51_13_20091203030103_crawl101-c/51_13_20091203041445_crawl101.arc.gz
server-timing: captures_list;dur=0.934999, exclusion.robots;dur=0.065179, exclusion.robots.policy;dur=0.051249, esindex;dur=0.014239, cdx.remote;dur=13.288347, LoadShardBlock;dur=304.743830, PetaboxLoader3.datanode;dur=217.008128, PetaboxLoader3.resolve;dur=71.104082, load_resource;dur=115.073969
x-app-server: wwwb-app224-dc8
x-ts: 200
x-tr: 515
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app224; 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=()
content-encoding: gzip
edspencer's jaml at master - GitHub
This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| Description: | JavaScript Haml edit |
| Homepage: | edit |
| Public Clone URL: |
git://github.com/edspencer/jaml.git
Give this clone URL to anyone.
git clone git://github.com/edspencer/jaml.git
|
| Your Clone URL: |
Use this clone URL yourself.
git clone git@github.com:edspencer/jaml.git
|
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:24:03 -0800 2009 | Updated with new version of Jaml [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!







