-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
54 lines (49 loc) · 857 Bytes
/
main.c
File metadata and controls
54 lines (49 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <unistd.h>
#include <string.h>
#define CTML_NOLIBC
#define CTML_PRETTY
#define CTML_CUSTOM_ATTRIBUTES X(toto);XL(da, data-attr);
#define CTML_IMPLEMENTATION
#include "ctml.h"
#include "ctml_short.h"
void sink(char* src, void*_) {
write(1, src, strlen(src));
}
void cbutton(CTML_Context* ctx) {
button(.class="btn-primary") {
ctml_raw("click");
}
}
void ui() {
{
ctml(
.sink=sink
) {
ctml_raw("<!DOCTYPE html>");
html(.lang="en") {
img(.src="https://google.com/toto.png")
div(.class="toto", .da="hey", .toto="hey") {
h1() {
ctml_raw("hello");
ctml_text("this is <strong>escaped</strong>");
ctml_raw("not <strong>escaped</strong>");
}
}
cbutton(ctx);
}
}
}
{
ctml(
.sink=sink
){
div() {
ctml_raw("another one");
}
}
}
}
int main() {
ui();
return 0;
}