This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

updating example

  • Loading branch information...
paularmstrong committed Sep 27, 2011
1 parent 2599c2d commit eddfdd4bd920124b73aff151c89474ac206836f2
Showing with 18 additions and 22 deletions.
  1. +18 −22 README.md
View
@@ -24,36 +24,32 @@ All documentation can be viewed online. [Documentation Table of Contents](https:
### Template code
- <h1>Example</h1>
- {% for name in names %}
- <p>
- {{ forloop.counter }}
- {# This is a comment #}
- {{ name }}{% if name == "Django" %} Reinhardt{% endif %}
- </p>
+ <h1>{{ pagename|title }}</h1>
+ <ul>
+ {% for author in authors %}
+ <li{% if forloop.index <= 0 %} class="first"{% endif %}>{{ author }}</li>
+ {% empty %}
+ <li>There are no authors.</li>
{% endfor %}
+ </ul>
### node.js code
var template = require('Swig');
- var tmpl = template.fromFile("/path/to/template.html");
- console.log(tmpl.render({names: ["Duke", "Django", "Louis"]}));
+ var tmpl = template.fromFile('/path/to/template.html');
+ tmpl.render({
+ pagename: 'awesome people',
+ authors: ['Paul', 'Jim', 'Jane']
+ });
### Output
- <h1>Example</h1>
- <p>
- 1
- Duke
- </p>
- <p>
- 2
- Django Reinhardt
- </p>
- <p>
- 3
- Louis
- </p>
+ <h1>Awesome People</h1>
+ <ul>
+ <li class="first">Paul</li>
+ <li>Jim</li>
+ <li>Jane</li>
+ </ul>
## How it works

0 comments on commit eddfdd4

Please sign in to comment.