-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3.11.0 - functional components
- Loading branch information
Showing
5 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<div> | ||
</div> | ||
<script src="testjs17.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import | ||
../src/happyx, | ||
std/macros | ||
|
||
|
||
var someValue = remember 0 | ||
|
||
proc funcComp1(i: State[int], stmt: TagRef): TagRef = | ||
## You can pass any amount of arguments. | ||
buildHtml: | ||
tDiv: | ||
"i is " | ||
{i} | ||
@click: | ||
i += 1 | ||
stmt | ||
|
||
# proc funcComp2(i: State[int]): TagRef = | ||
# buildHtml: | ||
# tDiv: | ||
# "comp2, so `i` is {i}" | ||
|
||
# proc funcComp3(): TagRef = | ||
# buildHtml: | ||
# tDiv: | ||
# "comp3 without arguments" | ||
|
||
proc funcComp4(stmt: TagRef): TagRef = | ||
static: | ||
echo declared(stmt) and stmt is TagRef | ||
buildHtml: | ||
tDiv: | ||
"comp4 with body" | ||
stmt | ||
|
||
|
||
# component NormalComp: | ||
# i: State[int] | ||
# html: | ||
# tDiv: | ||
# "And this is common component. i is {self.i}" | ||
|
||
|
||
appRoutes "app": | ||
"/": | ||
tDiv: | ||
# "Here is functional components" | ||
# funcComp1(someValue): | ||
# "This is functional component slot" | ||
# funcComp2(someValue) | ||
# funcComp3() | ||
# funcComp3 | ||
funcComp4(): | ||
"Hello" | ||
funcComp1(someValue): | ||
"This is functional component slot" | ||
!debugCurrent | ||
# funcComp4: | ||
# "world" | ||
# NormalComp(someValue) |