on master help sign in
Typo & syntax highlighting fixes in tutorial 4
7e4ca6fJasper Van der Jeugt
web/tutorials/04-compilers.markdown+9−5
@@ -41,9 +41,11 @@ Templates
41
41
42Let's have a look at a simple template:
42Let's have a look at a simple template:
43
43
44+```html
44− <h1>$title$</h1>
45+<h1>$title$</h1>
45− <div class="info">Posted on $date$</div>
46+<div class="info">Posted on $date$</div>
46− $body$
47+$body$
48+```
47
49
48As you can probably guess, template files just contain text and only the `$`
50As you can probably guess, template files just contain text and only the `$`
49character has special meaning: text between dollar signs ("fields") is replaced
51character has special meaning: text between dollar signs ("fields") is replaced
@@ -53,7 +55,9 @@ use `$$`.
53You usually compile the templates from disk using the aptly named
55You usually compile the templates from disk using the aptly named
54`templateCompiler`:
56`templateCompiler`:
55
57
58+```haskell
56− match "templates/*" $ compile templateCompiler
59+match "templates/*" $ compile templateCompiler
60+```
57
61
58Notice the lack of `route` here: this is because we don't need to write the
62Notice the lack of `route` here: this is because we don't need to write the
59templates to your `_site` folder, we just want to use them elsewhere.
63templates to your `_site` folder, we just want to use them elsewhere.
@@ -86,7 +90,7 @@ And `$title$` like this:
86
90
87```haskell
91```haskell
88titleContext :: Context a
92titleContext :: Context a
89−titleContext :: field "title" $ \item -> do
93+titleContext = field "title" $ \item -> do
90 metadata <- getMetadata (itemIdentifier item)
94 metadata <- getMetadata (itemIdentifier item)
91 return $ fromMaybe "No title" $ M.lookup "title" metadata
95 return $ fromMaybe "No title" $ M.lookup "title" metadata
92```
96```