UNPKG

5.05 kBMarkdownView Raw
1AE86 ![http://travis-ci.org/cliffano/ae86](https://secure.travis-ci.org/cliffano/ae86.png?branch=master)
2----
3
4AE86 is a static website generator written in Node.js .
5
6Installation
7------------
8
9 npm install -g ae86
10
11Usage
12-----
13
14Create new project with sample templates:
15
16 ae86 init
17
18* partials/ - directory containing partial templates
19* layouts/ - directory containing layout templates
20* pages/ - directory containing page templates
21* params.js - file containing custom tags and variables
22
23Generate the website, website will be written to out/ directory:
24
25 ae86 gen
26
27Watch the project, website will automatically be regenerated everytime there's a modified file:
28
29 ae86 watch
30
31Template & Parameters
32---------------------
33
34AE86 uses [shinetech/jazz](https://github.com/shinetech/jazz) as its template engine, checkout Jazz for further syntax documentation.
35
36__Partials__
37
38Partial templates can be used for fragments of the website, e.g. website header, footer, and navigation, that appear on multiple pages. Partial templates can be included in other templates using the include tag.
39
40__Layouts__
41
42Layout templates are applied to each page. By default, all pages use layouts/default.html unless otherwise specified in params.js' sitemap. Page content is rendered in layout using {content} param.
43
44__Pages__
45
46Each page template will be applied a layout and evaluated into a static HTML page.
47
48__Static__
49
50Place all static files (e.g. images, scripts, styles, robots.txt) in static directory. The directory structure of static files will be kept as-is. If there's any conflict with the page templates, the page template will overwrite the static file.
51
52__Parameters__
53
54Website parameters can be specified in exports.params object in params.js file:
55
56 exports.params = {
57 subtitle: 'Small, lightweight, since 1983.',
58 team: ['Keiichi Tsuchiya', 'Mitsu Ide', 'Dori-Kin']
59 }
60
61These parameters can then be used in a template file:
62
63 <h2>{subtitle}</h2>
64 <ul>
65 {foreach person in team}
66 <li>{person}</li>
67 {end}
68 </ul>
69
70You also need to specify the sitemap in params.js file. The key should match the page file names under the pages directory, title and layout can optionally be specified as the value. Layout value must be relative to layouts directory, e.g. layout: brochure.html uses layouts/brochure.html . If layout is not specified, then layouts/default.html will be used.
71
72 exports.params = {
73 sitemap: {
74 'index.html': { title: 'Home Page' },
75 'products/corolla.html': { title: 'Toyota Corolla', layout: 'brochure.html' },
76 'products/sprinter.html': { title: 'Toyota Sprinter', layout: 'brochure.html' },
77 'contact.html': { title: 'Contact Us' }
78 }
79 }
80
81Note that params.js is a Node.js module, so it can require other modules accordingly.
82
83__Custom Tags__
84
85Custom tag can be specified in params.js as a function:
86
87 exports.params = {
88 copyright: function (year, name, cb) {
89 cb('Copyright &copy; ' + year + ' ' + name + '. Some Rights Reserved.');
90 }
91 }
92
93Note that a custom tag function must have a callback(result) as the last argument, result will then be rendered on the template.
94
95The custom tag can then be used in a template file:
96
97 <div id="footer">
98 {copyright('2011', 'Toyota Motor Corporation')}
99 <div>
100
101__Built-in Tags & Variables__
102
103AE86 comes with a number of built-in tags and variables:
104
105* include(file)
106* title()
107* date(format)
108* relative(path)
109* __genId
110
111__include(file)__
112
113This tag includes a partial template in another template. The file argument is relative to partials directory. E.g. include('header.html') includes partials/header.html file.
114
115 <div id="header">
116 {include('header.html')}
117 </div>
118
119A partial template can also be included in another partial template.
120
121__title()__
122
123This tag displays the current page's title as configured in sitemap param in params.js .
124
125 <title>{title()}</title>
126
127__date(format)__
128
129This tag displays the current time with a specified format. Check out [felixge/node-dateformat](https://github.com/felixge/node-dateformat) README page for date format examples.
130
131 <div class="date">{date('dddd dd/mm/yyyy hh:MM:ssTT')}</div>
132
133__relative(path)__
134
135This tag renders a path relative to the location of the page template.
136
137 <script type="text/javascript" src="{relative('scripts/global.js')}"></script>
138
139Which will be rendered as ../scripts/global.js from templates under subdirectories of pages directory, but it will be rendered as scripts/global.js from templates right under the pages directory.
140
141____genId__
142
143This variable is an ID unique for each website generation (currently a timestamp). It's handy when you want to force the client browser to request a resource that should only be cached once for each version of the website, e.g. JavaScript, CSS, or image files.
144
145 <script type="text/javascript" src="{relative('scripts/global.js')}?{__genId}"></script>
146
147Colophon
148--------
149
150Follow [@cliffano](http://twitter.com/cliffano) on Twitter.