Static template generator for C
git clone git://soophie.de/ductape
blob: af0e2cdabf2f4326389a6b19246a009fab151df9 (794 bytes)[doc][blame][raw]
1
# ctl3
Static template generator for C5
## Usage7
```html8
% #include "src/ctl_macro.h" %10
% CTL_TEMPLDEF(11
example,12
char *title;13
) %15
<!DOCTYPE html>16
<html lang="en">17
<head>18
<title>% STRING(ctx->title) %</title>19
</head>20
</html>22
% CTL_ENDTEMPL %23
```25
```bash26
ctl -h example.html > ctl_example.h27
ctl -o example.html > ctl_example.so28
```30
```c31
#include <so/ctl.h>32
#include "ctl/ctl_example.h"34
#define CTL_DL_PATH($name) "./ctl_" #$name ".so"36
char *__out = NULL;38
void __ctl_write(const char *str) {39
str_append(&__out, (char *) str);40
}42
ctl_t __ctl = {43
.write = __ctl_write,44
};46
HTTP_GET("/example", example_page)47
example_t example = {48
.title = title,49
};50
return ctl_serve(&example, example_render, CTL_DL_PATH(example));51
}52
```54
```c55
#define STRING(x) ctl->write(x);56
```