~subsetpark/bagatto

ref: 075f758e48bb282b35b0df18a703af68da96e0c1 bagatto/demo/templates/posts.temple -rw-r--r-- 1.8 KiB
075f758e — Zach Smith Tweak subtitle 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{% (bagatto/include "templates/base_top") %}

<h2>{{ (get-in args [:config-json "subtitle"]) }}</h2>
<h3>Author: {{ (get-in args [:config-file :author]) }}</h3>
{$
### The posts index.

### We see here the use of functions from three different places:
### 1. the index file that `bag` was called with. In this case that's
###    the `post-path` function. This allows us to use the index module
###    as the source of truth for things like link destinations, rather
###    than having to write them out twice.
### 2. The `bagatto/` namespace. This is the same "standard library"
###    that's made available in the index module and constitutes the
###    loaders, renderers, and utilities provided by the bagatto
###    application.
### 3. Arbitrary, author-managed libraries. In addition to the bagatto
###    library, we've vendored the `hypertext` library in our demo
###    directory (ie, not as a part of bagatto proper). In this case it
###    was installed by `jpm install`, but we could just as easily manage
###    our own `project.janet` file in our site directory.

###    Since temple allows us to run arbitrary Janet code, we can then
###    `import` that library here and then use it to generate HTML,
###    instead of printing out HTML strings directly. `bag` will look for
###    the `JANET_PATH` system environment variable; therefore, if we run
###    `JANET_PATH=vendor bag index.janet` we can access any libraries we
###    ourselves would like to manage. $}

{$ (import hypertext) $}

{% (def img-path (path/join ".." (make-static-path args {:path "static/hello.png"}))) %}
{% (print (hypertext/markup (img :src img-path))) %}

<ul>
{% (loop [post :in (args :posts)]
     (def dest (make-post-path args post))
     (print (hypertext/markup
            (li (a :href dest
                   [(post :title)]))))) %}
</ul>

{% (bagatto/include "templates/base_bottom") %}