Blame


1 6509b181 2022-12-30 thomas {!
2 6509b181 2022-12-30 thomas #include <sys/queue.h>
3 6509b181 2022-12-30 thomas #include <string.h>
4 6509b181 2022-12-30 thomas #include "lists.h"
5 6509b181 2022-12-30 thomas #include "tmpl.h"
6 6509b181 2022-12-30 thomas
7 6509b181 2022-12-30 thomas int list(struct template *, struct tailhead *);
8 6509b181 2022-12-30 thomas int base(struct template *, struct tailhead *);
9 6509b181 2022-12-30 thomas
10 6509b181 2022-12-30 thomas !}
11 6509b181 2022-12-30 thomas
12 6509b181 2022-12-30 thomas {{ define base(struct template *tp, struct tailhead *head) }}
13 6509b181 2022-12-30 thomas <!doctype html>
14 6509b181 2022-12-30 thomas <html>
15 6509b181 2022-12-30 thomas <body>
16 6509b181 2022-12-30 thomas {{ render list(tp, head) }}
17 6509b181 2022-12-30 thomas </body>
18 6509b181 2022-12-30 thomas </html>
19 6509b181 2022-12-30 thomas {{ end }}
20 6509b181 2022-12-30 thomas
21 6509b181 2022-12-30 thomas {{ define list(struct template *tp, struct tailhead *head) }}
22 6509b181 2022-12-30 thomas {!
23 6509b181 2022-12-30 thomas struct entry *np;
24 6509b181 2022-12-30 thomas int i;
25 6509b181 2022-12-30 thomas !}
26 6509b181 2022-12-30 thomas {{ if !TAILQ_EMPTY(head) }}
27 6509b181 2022-12-30 thomas <p>items:</p>
28 6509b181 2022-12-30 thomas <ul>
29 6509b181 2022-12-30 thomas {{ tailq-foreach np head entries }}
30 6509b181 2022-12-30 thomas <li>{{ np->text }}</li>
31 6509b181 2022-12-30 thomas {{ end }}
32 6509b181 2022-12-30 thomas </ul>
33 6509b181 2022-12-30 thomas {{ else }}
34 6509b181 2022-12-30 thomas <p>no items</p>
35 6509b181 2022-12-30 thomas {{ end }}
36 6509b181 2022-12-30 thomas
37 6509b181 2022-12-30 thomas <p>
38 6509b181 2022-12-30 thomas {{ for i = 0; i < 3; ++i }}
39 6509b181 2022-12-30 thomas hello{{ " " }}
40 6509b181 2022-12-30 thomas {{ end }}
41 6509b181 2022-12-30 thomas world!
42 6509b181 2022-12-30 thomas </p>
43 6509b181 2022-12-30 thomas {{ end }}