so://phie

ductape

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

blob: af0e2cdabf2f4326389a6b19246a009fab151df9 (794 bytes)[doc][blame][raw]

1# ctl

2

3Static template generator for C

4

5## Usage

6

7```html

8% #include "src/ctl_macro.h" %

9

10% CTL_TEMPLDEF(

11 example,

12 char *title;

13) %

14

15<!DOCTYPE html>

16<html lang="en">

17 <head>

18 <title>% STRING(ctx->title) %</title>

19 </head>

20</html>

21

22% CTL_ENDTEMPL %

23```

24

25```bash

26ctl -h example.html > ctl_example.h

27ctl -o example.html > ctl_example.so

28```

29

30```c

31#include <so/ctl.h>

32#include "ctl/ctl_example.h"

33

34#define CTL_DL_PATH($name) "./ctl_" #$name ".so"

35

36char *__out = NULL;

37

38void __ctl_write(const char *str) {

39 str_append(&__out, (char *) str);

40}

41

42ctl_t __ctl = {

43 .write = __ctl_write,

44};

45

46HTTP_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```

53

54```c

55#define STRING(x) ctl->write(x);

56```