The content String.
The content String.
We override buildString for performance - allowing text to not be escaped until passed in the final StringBuilder to encode it into.
We override buildString for performance - allowing text to not be escaped until passed in the final StringBuilder to encode it into.
An alternative way of implementing this would be to make HtmlFormat.escape return a subclass of Html with a custom buildString implementation. While this does significantly improve performance if a template needs to escape a lot of Strings, if it doesn't, performance actually goes down (measured 10%), due to the fact that the JVM can't optimise the invocation of buildString as well because there are two different possible implementations.
Content type of HTML.
Sub elements to traverse when creating the resultant string
Sub elements to traverse when creating the resultant string
Formatted content
Formatted content
Content type used in default HTML templates.
This has 3 states, either it's a tree of elements, or a leaf, if it's a leaf, it's either safe text, or unsafe text that needs to be escaped when written out.