Replies: 1 comment 4 replies
-
Wouldn't this work just fine with a normal component created along the lines of your |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey y'all. Thanks for making Sveltekit. It is amazing and I keep finding new cool things.
I recently ran across https://github.com/ciscoheat/sveltekit-superforms which works as a wrapper for ZOD. It uses one schema setup to validate both server and client side. It's very cool.
The only issue I have is the problem we all have with forms: a lot of boiler plate.
To get a fully functioning form input we need at minimum:
when only the name and type need to be changed for different inputs.
I was thinking this could easily be reduced to a single line by creating a macro.js file which would export functions and return template literals. These would be run and replace the text in the file to be compiled, kinda like WTForms does for python in flask.
The way I envision it working, in pseudocode. We'd create whatever input types we need something like this...
macro.js
In the +page.svelte file we'd add an import
and it would be used like this
If I do this as {@html INPUT('email', 'text')} it looks like it works but, of course, the data binding doesn't function. It runs the INPUT function and returns the string properly but doesn't do the second pass required to see the binding.
That's why I was thinking a pre-processor that would see the @macro and simply replace that line of code with the string literal before continuing to compile would be easy.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions