Logo

index : htmltemplate

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/htmltemplate.git/html/examples/01_from_readme.jai blob: daf48ade4a2fc833e9d5ce6e17c9b961a1f7eaf8 [raw] [clear marker]

        
0#import "Basic";
1#import "htmltemplate"();
2
3
4/**
5 jai 01_from_readme.jai -quiet && ./01_from_readme
6*/
7
8
9TEMPLATE :: #string STR_END
10<div>
11 <p>{{ :foo1: }}</p>
12
13 {{ :foo2: <a href="%" %>%</a> }}
14
15 {{ :foo3: <a href="#%1" target="%2">%1</a> }}
16
17 <ul>
18{{ loop:foo4: <li><a href="#%1">%1</a>%2</li> }}
19 </ul>
20</div>
21STR_END;
22
23
24main :: () {
25 queue_action: [..]Action;
26 defer array_free(queue_action);
27
28 commit("foo1", "My Title");
29 commit("foo2", "#about", "target=\"_self\"", "About");
30 commit("foo3", "blog", "_self");
31 commit("foo4", .[
32 .["Foo", "Bar"],
33 .["Fizz", "Buzz"],
34 .["contact", ""],
35 ]);
36
37 success,
38 html_string,
39 exit_code,
40 error_message := generate(queue_action, TEMPLATE, .STRING);
41
42 defer {
43 free(html_string);
44 free(error_message);
45 }
46
47 if !success {
48 log("%", error_message);
49 return;
50 }
51
52 log("%", html_string);
53}
54
55
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit