Repository navigation
v0.5.1
SPA, States And More Other 🎉
In this release we added powerful state management and components!
Components
Project structure:
project/
-- components/
-- -- hello_world.nim
-- main.nim
project/components/hello_world.nim
import happyx
component MyComponent:
counter: int
`template`:
{self.counter}
button:
"Increase"
@click:
self.counter += 1
`script`:
echo self.counter
`style`:
"""
button {
background: #212121;
color: #dfdfdf;
padding: 12px {self.counter + 1}px;
}
"""project/main.nim
import happyx
var app = registerApp()
app.routes:
"/":
component MyComponent(counter = 5)
app.start()