|
@@ -32,7 +32,7 @@ Every page other than those in the `posts/` directory is an `index`.
|
32
|
32
|
|
33
|
33
|
**Every** page uses the `base.tmpl` and fills in the content using
|
34
|
34
|
either the `post` or `index` templates. No important logic should be
|
35
|
|
-in *any* template, they are only used to give provide consistent layout.
|
|
35
|
+in *any* template, they are only used to provide a consistent layout.
|
36
|
36
|
|
37
|
37
|
* `base.tmpl` This template generates the outer shell of the HTML.
|
38
|
38
|
It keeps a consistent look and feel for all pages in the blog. The
|
|
@@ -64,7 +64,7 @@ simplest to either modify the existing default theme, `hyde`, or copy
|
64
|
64
|
it in entirety and then tweak only the CSS of your new theme. A large
|
65
|
65
|
amount of visual difference can be had with a minimum of (or no)
|
66
|
66
|
template hacking. There is plenty of advice on CSS styling on the web.
|
67
|
|
-I'm no expert but feel free to send pull requests modifying theme's
|
|
67
|
+I'm no expert but feel free to send pull requests modifying a theme's
|
68
|
68
|
CSS or improving this section, perhaps by recommending a CSS resource.
|
69
|
69
|
|
70
|
70
|
## Creating a Theme from Scratch (with code)
|
|
@@ -114,10 +114,15 @@ The templating language is documented [elsewhere][clt].
|
114
|
114
|
However as a short primer:
|
115
|
115
|
|
116
|
116
|
* Everything is output literally, except template commands.
|
117
|
|
-* Template commands are enclosed in `{` and `}`
|
|
117
|
+* Template commands are enclosed in `{` and `}`.
|
118
|
118
|
* Variables, which are provided by coleslaw, can be referenced
|
119
|
119
|
inside a template command. So to use a variable you have to say
|
120
|
120
|
`{$variable}` or `{$variable.key}`.
|
|
121
|
+ **WARNING**: At present, cl-closure-template does not have great debugging.
|
|
122
|
+ If you typo this, e.g. `${variable}`, you will receive an *uninformative*
|
|
123
|
+ and apparently unrelated error. Also, attempted access of non-existent keys
|
|
124
|
+ fails silently. We are exploring options for making debugging easier in a
|
|
125
|
+ future release.
|
121
|
126
|
* If statements are written as `{if ...} ... {else} ... {/if}`.
|
122
|
127
|
Typical examples are: `{if $injections.body} ... {/if}` or
|
123
|
128
|
`{if not isLast($link)} ... {/if}`.
|
|
@@ -139,19 +144,16 @@ The variable that should be available to all templates is:
|
139
|
144
|
#### Index Template Variables
|
140
|
145
|
|
141
|
146
|
- **tags** A list containing all the tags, each with keys
|
142
|
|
- `.name` and `.slug`.
|
143
|
|
-- **months** A list of all months with posts as `yyyy-mm` strings.
|
|
147
|
+ `name` and `url`.
|
|
148
|
+- **months** A list of all the content months, each with keys
|
|
149
|
+ `name` and `url`.
|
144
|
150
|
- **index** This is the meat of the content. This variable has
|
145
|
151
|
the following keys:
|
146
|
|
- - `id`, the name of the page that will be rendered
|
147
|
152
|
- `content`, a list of content (see below)
|
148
|
|
- - `title`, a string title to display to the user
|
149
|
|
-- **prev** If this index file is part of a chain, the `id`
|
150
|
|
- of the previous index html in the chain.
|
151
|
|
- If this is the first file, the value will be empty.
|
152
|
|
-- **next** If this index file is part of a chain, the `id`
|
153
|
|
- of the next index html in the chain.
|
154
|
|
- If this is the last file, the value will be empty.
|
|
153
|
+ - `name`, a name to use in links or href tags
|
|
154
|
+ - `title`, a title to use in H1 or header tags
|
|
155
|
+- **prev** Nil or the previous index with keys: `url` and `title`.
|
|
156
|
+- **next** Nil or the next index with keys: `url` and `title`.
|
155
|
157
|
|
156
|
158
|
#### Post Template Variable
|
157
|
159
|
|
|
@@ -160,8 +162,8 @@ The variable that should be available to all templates is:
|
160
|
162
|
- **post** All these variables are post objects. **prev** and
|
161
|
163
|
**next** are the adjacent posts when put in
|
162
|
164
|
chronological order. Each post has the following keys:
|
163
|
|
- - `tags`, a list of tags (each with keys `name` and `slug`)
|
164
|
|
- - `slug`, the slug of the post
|
|
165
|
+ - `url`, the relative url of the post
|
|
166
|
+ - `tags`, a list of tags (each with keys `name` and `url`)
|
165
|
167
|
- `date`, the date of posting
|
166
|
168
|
- `text`, the HTML of the post's body
|
167
|
169
|
- `title`, the title of the post
|
|
@@ -190,8 +192,8 @@ A simple `index.tmpl` looks like this:
|
190
|
192
|
{namespace coleslaw.theme.trivial}
|
191
|
193
|
{template index}
|
192
|
194
|
{foreach $obj in $index.content}
|
193
|
|
-<h1>{$obj.title}</h1>
|
194
|
|
- {$obj.text |noAutoescape}
|
|
195
|
+<h1>{$object.title}</h1>
|
|
196
|
+ {$object.text |noAutoescape}
|
195
|
197
|
{/foreach}
|
196
|
198
|
{/template}
|
197
|
199
|
```
|
|
@@ -209,14 +211,7 @@ And a simple `post.tmpl` is similarly:
|
209
|
211
|
|
210
|
212
|
All of the files are now populated with content. There are still no links
|
211
|
213
|
between the pages so navigation is cumbersome but adding links is simple.
|
212
|
|
-Good luck!
|
213
|
|
-
|
214
|
|
-## Note on adding links
|
215
|
|
-
|
216
|
|
-As mentioned earlier, most files have a file name which is a slug of
|
217
|
|
-some sort. So if you want to create a link to a tag file you should
|
218
|
|
-do something like this:
|
219
|
|
-`<a href="${config.domain}/tags/{$tag.slug}.{$config.pageExt}">{$tag.name}</a>`.
|
|
214
|
+Just do: `<a href="{$config.domain}/{$object.url}">{$object.name}</a>`.
|
220
|
215
|
|
221
|
216
|
[clt]: https://developers.google.com/closure/templates/
|
222
|
217
|
[ovr]: https://github.com/redline6561/coleslaw/blob/master/docs/overview.md
|