nicojs / typed-html

TypeSafe HTML templates using TypeScript. No need to learn a template library.
333 stars 51 forks source link

feat - Support React-style children #16

Closed bebraw closed 3 years ago

bebraw commented 4 years ago

After using typed-html a while at tailwind-webpack-starter, I started missing React-style children as that would simplify some of the code and make it feel more familiar.

I see my editor applied some formatting changes to the code. I can revert those if you prefer. I guess ideally we would have Prettier set up in the project as that would solve these kind of problems.

marcj commented 3 years ago

@bebraw awesome! Exactly what is missing to build something more serious. @nicojs are you interested in merging this?

bebraw commented 3 years ago

@marcj This might need more work and tuning but it's definitely worth a look.

One question is, should we simply drop the old syntax where contents are passed as the second parameter and go straight with React-style for children?

Another question is, should we support React-style fragments as well? My understanding is that this should be fairly simple (another field in configuration).

nicojs commented 3 years ago

I see my editor applied some formatting changes to the code. I can revert those if you prefer. I guess ideally we would have Prettier set up in the project as that would solve these kind of problems.

Yeah, planning to do that. You're forgiven for now 😉

EDIT: Ahh man. Four space indent? What was I thinking? 🙄

marcj commented 3 years ago

@bebraw If you ask me, then yes and yes. :) But it's of course up to @nicojs. I'd love to integrate this lib into a new server framework that would use this as template engine, so the more features it has that are required for "serious" apps, the better. 😅

marcj commented 3 years ago

Oh nevermind, I just saw this does not have a OSS license. @nicojs do you plan to make this OSS?

nicojs commented 3 years ago

Yes, should have Apache-2. PRs welcome :)

bebraw commented 3 years ago

@nicojs I did the changes (sorry for the delay 😄 ).

I would probably drop the old way of handling children altogether and go with React-style as that's kind of standard but that's up to you.

bebraw commented 3 years ago

Any thoughts on this? Should we finish up the PR?