so://phie

ductape

Static template generator for C
git clone git://soophie.de/ductape

blob: e8882c47f4e921a32376a22efebe126ff36c6bbc (575 bytes)[doc][blame][raw]

1# ctl

2

3Static template generator for C

4

5## Usage

6

7```html

8<h1>Hello, % STRING(name) %!</h1>

9<ul>

10 % for (int i = 0; i < len; i++) { %

11 <li>Item % NUMBER(i) %</li>

12 % } %

13</ul>

14```

15

16```bash

17ctl example.html > ctl_example.h

18```

19

20```c

21#define LIB_CTL_IMPL

22#include <libctl.h>

23

24#define CTL_OUT(out, x) { \

25 str_append(out, x); \

26}

27#define STRING(x) str_append(ctl_out, x);

28#define NUMBER(x) { \

29 str_appendf(ctl_out, "%d", x); \

30}

31

32void ctl_fn_example(char **ctl_out, ctl_ctx_t ctx) {

33 (void) ctx;

34 char *name = "world";

35 int len = 10;

36 #include "ctl_example.h"

37}

38```