-
Notifications
You must be signed in to change notification settings - Fork 0
/
component-test.lua
49 lines (40 loc) · 1.23 KB
/
component-test.lua
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
local xml_gen = require("xml-generator")
local xml = xml_gen.xml
local tw = xml_gen.namespace "tw"
math.randomseed(os.time())
local header = xml_gen.component(function (args, kids)
return xml.head {
xml.title(args.title);
xml.meta {
name="viewport",
content="width=device-width, initial-scale=1"
};
kids;
args.css_framework;
}
end)
local random_number = xml_gen.component(function (args)
return xml.p(math.random(args.min, args.max))
end)
local yield = coroutine.yield
local doc = xml_gen.declare_generator(function ()
---@diagnostic disable: undefined-global
return html {charset="utf8"} {
header {title="Hello, World!", css_framework=link {rel="stylesheet", href="..."}};
body {
h1 {class="text-center"} "Fritsite";
main {class="container"} {
p "Hello, World!";
button {onclick="say_hi()"} "Say Hi!";
};
function ()
for i = 1, 10 do
yield(random_number {id="rn-"..i} {min=1, max=100})
end
end;
tw.div {id="test div"} "hello"
};
}
---@diagnostic enable: undefined-global
end)
print(doc())