tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.
https://j2html.com/
Apache License 2.0
765 stars 136 forks source link

Tag class per HTML element #116

Closed mkopylec closed 5 years ago

mkopylec commented 6 years ago

The API of j2html would become much more type safe if every HTML element had each own representation class that extends either ContainerTag or EmptyTag. Each HTML element class could then have each own set of predefined HTML attributes. Working with that kind of API would be much more comfortable, but it is quite a lot of work to implement it in j2html. Is there any chance to provide such API or maybe you are open for pull request?

tipsy commented 6 years ago

@mkopylec I'm always open to pull requests. This change would massively increase the codebase, so please start with a small proof of concept that can be reviewed first.

Edit: Accidentally sent before I finished writing.

mkopylec commented 6 years ago

The amount of code will surely increase, but users of the library will have a lot nicer API to use. I will create a small PoC.

mkopylec commented 6 years ago

Check out https://github.com/tipsy/j2html/pull/117

mwanji commented 6 years ago

This is interesting! I created my own PoC, using JavaPoet to generate the code: #121

ghost commented 5 years ago

@mkopylec There are other APIs providing such features (including htmlFlow), maybe j2html's developers prefer keeping it simple.

mkopylec commented 5 years ago

@gouessej It looks promising, thanks.

ghost commented 5 years ago

@mkopylec You're welcome. Feel free to try my flowifier, I've just tested against Wikipedia's homepage, it helps to generate some Java source code from existing HTML source code.