tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.

Home Page:https://j2html.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide XHTML Mode for TagCreator

nickman opened this issue · comments

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 !

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