Skip to content

Commit

Permalink
Added -each docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 8, 2010
1 parent e8b1408 commit 77fa5ca
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Readme.md
Expand Up @@ -15,6 +15,7 @@
- optional memory caching
- combine dynamic and static tag classes
- supports [Express JS](http://expressjs.com)
- transparent iteration over objects, arrays, and even non-enumerables via `- each`
- no tag prefix
- filters
- :sass must have [sass.js](http://github.com/visionmedia/sass.js) installed
Expand Down Expand Up @@ -267,6 +268,44 @@ you may use `!=`:

p!= aVarContainingMoreHTML

The on exception made in terms of allowing "vanilla" JavaScript, is
the `- each` token. This takes the form of:

- each VAL[, KEY] in OBJ

An example iterating over an array:

- var items = ["one", "two", "three"]
- each item in items
li= item

outputs:

<li>one</li>
<li>two</li>
<li>three</li>

iterating an object's keys and values:

- var obj = { foo: 'bar' }
- each val, key in obj
li #{key}: #{val}

would output `<li>foo: bar</li>`

Non-enumerables are simply passed as the **only** value:

- each n in 15
li= n

would simply output `<li>15</li>`

You can also nest these!

- each user in users
- each role in user.roles
li= role

## bin/jade

Output html to _stdout_:
Expand Down

0 comments on commit 77fa5ca

Please sign in to comment.