fastn-stack / fastn

🚧 (Alpha stage software) fastn - better way to build websites 🚧
https://fastn.com
GNU Affero General Public License v3.0
465 stars 36 forks source link

Conditional attribute don't work with the `$on-click$` attribute #1895

Open siddhantk232 opened 4 months ago

siddhantk232 commented 4 months ago
-- string $val: click me

-- optional string $msg:

-- ftd.text: $val
$on-click$: ftd.set-string($a = $msg, v = I'll be called)
$on-click$ if { msg != NULL }: ftd.set-string($a = $msg, v = some other message)
$on-click$ if { msg == NULL }: ftd.set-string($a = $msg, v = some message)
$on-click$: ftd.set-string($a = $val, v = the last click event handler)

-- ftd.text: $msg
if: { msg }

Seems like the $on-click$ does not support conditionals. The above snippet will execute all the click handlers in order. You can change the order of the middle two $on-click$, the value of $msg will be equal to whatever is set by the last click handler ("some message" for the above snippet)