Skip to content

v0.5.1

Choose a tag to compare

@Ethosa Ethosa released this 18 Apr 14:43
· 1282 commits to master since this release

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()