Fix document(HtmlTag) in TagCreator
There is this method in TagCreator:
public static String document(HtmlTag htmlTag) {
return document().render() + htmlTag.render();
}
This returns a String by calling render(), thus it prevents using the new render possibilities introduced with https://github.com/tipsy/j2html/pull/179
A better approach would be if there is a Document class that implements Renderable and that handles the correct rendering.
Apparently this would break code written for j2html 1.*, so it is something we should consider for a 2.* release.
That method is also inefficient given it renders the entire document and then does a string concatenation, duplicating the whole thing, instead of just writing to a StringBuilder, It could be updated to render to a shared StringBuilder and the unescaped text object doesn't even need to be created. But for version 2 I agree it should be its own type.
htmlTag.render(FlatHtml.inMemory(Config.global()).appendUnescapedText("<!DOCTYPE html>"), null);