forked from HapticX/happyx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testjs14.nim
94 lines (75 loc) · 1.63 KB
/
testjs14.nim
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import ../src/happyx
component CTestChild:
id: int
color: cstring
`template`:
tDiv(style=fmt"color:{self.color};"):
"subcomponent ID: {self.id}"
var ctest1 = use component CTestChild(id=1, color = "green")
component CTest:
id: int
newId: cstring = "newId: " & $id
message: cstring = ""
child: CTestChild = use component CTestChild(id = self.id.val, color ="red")
`template`:
self.child.val
script: """
var x = 0
"""
#component self.child
tDiv: "template: {self.id} {self.newId}"
var test1 = use component CTest(id = 1)
var catStatus: string
var catLife: bool = false
if catLife:
catStatus = "alive"
else:
catStatus = "dead"
component Container:
`template`:
tSpan:
slot
var grandCount: int = 0
proc nextCount(): int =
grandCount += 1
result = grandCount
component Counter:
n: int = nextCount()
`template`:
"{self.n} )"
component withCounter:
n: int = 9
`template`:
component Container:
# tSpan:
for i in 1..self.n.val:
component Counter
appRoutes("app"):
"/":
tDiv: test1
tDiv: CTest(id = 7)
tDiv: CTest(9)
tDiv:
CTest(id = 0):
"hello"
@GetUserAgent
"/issue154":
tDiv:
"Your user agent is"
{userAgent}
tDiv: {catStatus}
var
dogStatus = "superposition"
dogLife: bool = false
if dogLife:
dogStatus = "alive"
else:
dogStatus = "dead"
tDiv(style="color:red;"): # <- for this
{dogStatus}
# Attrs declaration for tDiv with `style`
myAttr := "asd"
myAttr1 := 1123
"/issue171":
for i in 1..10:
component withCounter