forked from HapticX/happyx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testjs1.nim
82 lines (75 loc) · 1.38 KB
/
testjs1.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
import ../src/happyx
type
TestEnum = enum
teOne,
teTwo,
teThree,
teFour,
teFive
var
state = remember true
state1 = remember 1
state2 = remember @["h1", "h2", "h3", "h4", "h5", "h6"]
state3 = teTwo
var html =
buildHtml(tDiv):
!DOCTYPE html
tH1(class="myClass", style="color: red"):
"Hello, world!"
# Different styles of tag naming
# <h1></h1>
hH1
tagH1
tH1
if state: # IF-ELIF-ELSE
tDiv:
"True!"
tButton:
"click"
elif state1 == 2:
"State is 2"
else:
"False :("
if state1 == 1: # Just IF
tH1:
"Hello!"
tInput(`type`="password")
tButton:
"click!"
for i in state2: # FOR STMT
i
tDiv(style="background: red"):
for i in state2: # FOR STMT
"current tag is {i}"
{i}
tagTextarea(style = "font-weight: 500; margin-bottom: 10px;"):
"Hello, world"
# VARIABLES
{state}
{state1}
{state2}
# CASE-OF STMT
case state3:
of teOne:
tH1:
"Hello"
of teTwo:
tH2:
"Hi"
of teThree:
tH3:
"Oops"
rawHtml: """
<div>
<input type="password" />
<hr>
<script>
var x = "Hello, world!";
</script>
</div>
"""
rawHtml: """
Hello, world!
"""
html.get("input")["class"] = "a"
echo html