QUOTE: Love yourself first, then others.

README.md - ctl - Static template generator for C

ctl

Static template generator for C
git clone git@soophie.de:/srv/git/ctl
log | files | refs | readme

README.md (575B)


      1 # ctl
      2 
      3 Static 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
     17 ctl 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 
     32 void 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 ```