tipsy / j2html

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

Provide XHTML Mode for TagCreator #98

Closed nickman closed 6 years ago

nickman commented 6 years ago

It would be useful to be able to put TagCreator into XHTML compliant mode. At the very least, this would ensure that all tags are closed. For example, I found that when attempting to parse the generated HTML with an XML parser (using itext to generate PDFs from the HTML), it would complain about unclosed tags. For example, I had to replace img().withSrc("/img/hello.png") with rawHtml("<img src=\"/img/hello.png\"></img>")

In my imagined XHTML mode, the first code snippet would generate [X]HTML like this: <img src="/img/hello.png"></img>

Thanks !

nickman commented 6 years ago

On further digging, Config.closeEmptyTags does address this. At least, it did fix my Image tag issue.