Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 76 lines (54 sloc) 2.854 kB
7d19a46 @paularmstrong version bump 0.9.0
paularmstrong authored
1 Swig [![Build Status](https://secure.travis-ci.org/paularmstrong/swig.png)](http://travis-ci.org/paularmstrong/swig)
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
2 ====
0eac08c @skid Initial Commit
skid authored
3
2599c2d @paularmstrong update readme intro
paularmstrong authored
4 [Swig](http://paularmstrong.github.com/swig/) is a fast, Django-like template engine for node.js.
0eac08c @skid Initial Commit
skid authored
5
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
6 Features
7 --------
fa1cc2c @paularmstrong started a Features section for the README
paularmstrong authored
8
0975001 @paularmstrong updating how it works and template syntax in readme
paularmstrong authored
9 * Incredibly [fast][1]!
0d2c075 @paularmstrong updating docs for browser
paularmstrong authored
10 * Available for node.js **and** major web browsers!
057fa38 @paularmstrong update feature list in readme
paularmstrong authored
11 * [Express](http://expressjs.com/) compatible.
12 * Object-Oriented template inheritance.
13 * Apply filters and transformations to output in your templates.
14 * Automatically escapes all output.
15 * Lots of iteration and conditionals supported.
16 * Extendable and customizable.
fa1cc2c @paularmstrong started a Features section for the README
paularmstrong authored
17
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
18 Installation
19 ------------
8fbe0a3 @paularmstrong add install instructions. should probably mention it's on npm... ya k…
paularmstrong authored
20
21 npm install swig
22
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
23 Documentation
24 -------------
8a4c46d @paularmstrong add a documentation index and link from the readme
paularmstrong authored
25
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
26 All documentation can be viewed online. [Documentation Table of Contents](https://github.com/paularmstrong/swig/tree/master/docs#readme)
8a4c46d @paularmstrong add a documentation index and link from the readme
paularmstrong authored
27
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
28 Basic Example
29 -------------
23ea88f @paularmstrong updating readme for filters
paularmstrong authored
30
2370d2b @paularmstrong breaking out the docs and cleaning up the README a bit
paularmstrong authored
31 ### Template code
0eac08c @skid Initial Commit
skid authored
32
eddfdd4 @paularmstrong updating example
paularmstrong authored
33 <h1>{{ pagename|title }}</h1>
34 <ul>
35 {% for author in authors %}
c57c65e @paularmstrong Change `forloop` vars to `loop`
paularmstrong authored
36 <li{% if loop.index <= 0 %} class="first"{% endif %}>{{ author }}</li>
749bc65 @paularmstrong Change `empty` tag to `else`
paularmstrong authored
37 {% else %}
eddfdd4 @paularmstrong updating example
paularmstrong authored
38 <li>There are no authors.</li>
c4795ab @paularmstrong Require using end<tagname> like `endif` and `endfor` for all tags.
paularmstrong authored
39 {% endfor %}
eddfdd4 @paularmstrong updating example
paularmstrong authored
40 </ul>
2370d2b @paularmstrong breaking out the docs and cleaning up the README a bit
paularmstrong authored
41
42 ### node.js code
0eac08c @skid Initial Commit
skid authored
43
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
44 var template = require('swig');
ae9f134 @paularmstrong replace 'fromFile' with 'compileFile'
paularmstrong authored
45 var tmpl = template.compileFile('/path/to/template.html');
eddfdd4 @paularmstrong updating example
paularmstrong authored
46 tmpl.render({
47 pagename: 'awesome people',
48 authors: ['Paul', 'Jim', 'Jane']
49 });
0eac08c @skid Initial Commit
skid authored
50
2370d2b @paularmstrong breaking out the docs and cleaning up the README a bit
paularmstrong authored
51 ### Output
52
eddfdd4 @paularmstrong updating example
paularmstrong authored
53 <h1>Awesome People</h1>
54 <ul>
55 <li class="first">Paul</li>
56 <li>Jim</li>
57 <li>Jane</li>
58 </ul>
2370d2b @paularmstrong breaking out the docs and cleaning up the README a bit
paularmstrong authored
59
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
60 How it works
61 ------------
0eac08c @skid Initial Commit
skid authored
62
0975001 @paularmstrong updating how it works and template syntax in readme
paularmstrong authored
63 Swig reads template files and translates them into cached javascript functions. When we later render a template we call the evaluated function, passing a context object as an argument. This makes the rendering [_very fast_][1].
0eac08c @skid Initial Commit
skid authored
64
e4c485e @paularmstrong update documentation formatting
paularmstrong authored
65 License
66 -------
72f5ae3 @skid Added Message
skid authored
67
3a72f33 @paularmstrong updating license, adding license file
paularmstrong authored
68 Copyright (c) 2010-2011 Paul Armstrong, Dusko Jordanovski
72f5ae3 @skid Added Message
skid authored
69
70 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
71
72 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
74 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0975001 @paularmstrong updating how it works and template syntax in readme
paularmstrong authored
75
76 [1]: http://paularmstrong.github.com/node-templates/
Something went wrong with that request. Please try again.