From 0e4b002615b360284b43b5ceee6feb3ed8c1b72f Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 25 Aug 2023 10:41:54 +0530 Subject: feat: adds do expressions --- TODO.norg | 3 ++- examples/form/signup.css | 6 ++++-- src/eval.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/TODO.norg b/TODO.norg index 8be3a55..3d052cf 100644 --- a/TODO.norg +++ b/TODO.norg @@ -5,8 +5,9 @@ - (x) re-quotify value - (x) analog + digital clock example - (x) error handling try - - ( ) Scoped catch on try + - (x) Scoped catch on try - ( ) `do` expression + - ( ) `let` expression - ( ) `has-class` - ( ) `add-class` & `remove-class` should use self if id is not specified? - ( ) Update `--cssx-text` on update diff --git a/examples/form/signup.css b/examples/form/signup.css index 3811c42..2335334 100644 --- a/examples/form/signup.css +++ b/examples/form/signup.css @@ -30,11 +30,13 @@ prevent-default() add-class(form, 'submitting') try( - request('https://jksldjflksdjlfsd.com/wow'), + do( + request('/examples'), + add-class(form, 'submitted') + ), js-eval(string('alert("', get-var(--error), '")')) ) remove-class(form, 'submitting') - add-class(form, 'submitted') ; --cssx-children: input#input-email input#input-password #actions #message; diff --git a/src/eval.ts b/src/eval.ts index 17e27b1..1b5aace 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -332,6 +332,14 @@ const getFunctions = ( } }, + do: async () => { + let result = EvalValue.Void() + for (const expr of args) { + result = await evalExpr(expr, actions) + } + return result + }, + _: () => Promise.reject(new Error(`Not implemented: ${name}`)), }) } -- cgit v1.3.1