HapticX / happyx

Macro-oriented asynchronous web-framework written in Nim with ♥
https://hapticx.github.io/happyx/
MIT License
540 stars 18 forks source link

add boolean attributes #345

Closed Ethosa closed 1 month ago

Ethosa commented 1 month ago
var isReadonly = remember true

appRoutes "app":
  "/":
    tInput(value = "hello world", readonly = isReadonly)
    tButton:
      "switch"
      @click:
        isReadonly.set(not isReadonly)

HappyX will render it as

<input value="hello world">

and if isReadonly wil be true

<input value="hello world" readonly>

Attributes can be named with -:

tButton(data-happyx-ok = "Hello from HappyX"):
  "Hello world"

will be rendered as

<button data-happyx-ok="Hello from HappyX">Hello world</button>