Package freemarker.core
Class HTMLOutputFormat
Represents the HTML output format (MIME type "text/html", name "HTML"). This format escapes by default (via
StringUtil.XHTMLEnc(String)
). The ?html
, ?xhtml
and ?xml
built-ins silently bypass
template output values of the type produced by this output format (TemplateHTMLOutputModel
).
This class was final before 2.3.29.
- Since:
- 2.3.24
-
Field Summary
Modifier and TypeFieldDescriptionstatic HTMLOutputFormat
The only instance (singleton) of thisOutputFormat
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionescapePlainText(String plainTextContent)
Should give the same result asMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel)
, but the implementation may use a more efficient solution.Returns the MIME type of the output format.getName()
The short name used to refer to this format (like in the#ftl
header).boolean
isLegacyBuiltInBypassed(String builtInName)
Tells if a string built-in that can't handle aTemplateMarkupOutputModel
left hand operand can bypass this object as is.protected TemplateHTMLOutputModel
newTemplateMarkupOutputModel(String plainTextContent, String markupContent)
Creates a newCommonTemplateMarkupOutputModel
that's bound to thisOutputFormat
instance.void
Equivalent to callingMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.output(TemplateMarkupOutputModel, Writer)
, but the implementation may use a more efficient solution.Methods inherited from class freemarker.core.CommonMarkupOutputFormat
concat, fromMarkup, fromPlainTextByEscaping, getMarkupString, getSourcePlainText, isAutoEscapedByDefault, isEmpty, isOutputFormatMixingAllowed, output
Methods inherited from class freemarker.core.MarkupOutputFormat
outputForeign
Methods inherited from class freemarker.core.OutputFormat
toString, toStringExtraProperties
-
Field Details
-
INSTANCE
The only instance (singleton) of thisOutputFormat
.
-
-
Constructor Details
-
HTMLOutputFormat
protected HTMLOutputFormat()- Since:
- 2.3.29
-
-
Method Details
-
getName
Description copied from class:OutputFormat
The short name used to refer to this format (like in the#ftl
header).- Specified by:
getName
in classOutputFormat
-
getMimeType
Description copied from class:OutputFormat
Returns the MIME type of the output format. This might comes handy when generating a HTTP response.null
null
if this output format doesn't clearly corresponds to a specific MIME type.- Specified by:
getMimeType
in classOutputFormat
-
output
Description copied from class:MarkupOutputFormat
Equivalent to callingMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.output(TemplateMarkupOutputModel, Writer)
, but the implementation may use a more efficient solution.- Specified by:
output
in classCommonMarkupOutputFormat<TemplateHTMLOutputModel>
- Throws:
IOException
TemplateModelException
-
escapePlainText
Description copied from class:MarkupOutputFormat
Should give the same result asMarkupOutputFormat.fromPlainTextByEscaping(String)
and thenMarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel)
, but the implementation may use a more efficient solution.- Specified by:
escapePlainText
in classMarkupOutputFormat<TemplateHTMLOutputModel>
-
isLegacyBuiltInBypassed
Description copied from class:MarkupOutputFormat
Tells if a string built-in that can't handle aTemplateMarkupOutputModel
left hand operand can bypass this object as is. A typical such case would be when aTemplateHTMLOutputModel
of "HTML" format bypasses?html
.- Specified by:
isLegacyBuiltInBypassed
in classMarkupOutputFormat<TemplateHTMLOutputModel>
-
newTemplateMarkupOutputModel
protected TemplateHTMLOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent)Description copied from class:CommonMarkupOutputFormat
Creates a newCommonTemplateMarkupOutputModel
that's bound to thisOutputFormat
instance. When this is called fromCommonMarkupOutputFormat
, exactly one of the parameters will be non-null
.- Specified by:
newTemplateMarkupOutputModel
in classCommonMarkupOutputFormat<TemplateHTMLOutputModel>
- Parameters:
plainTextContent
-null
if the content is markup that possibly can be described as plain text without loss.markupContent
- Typically will benull
ifplainTextContent
is notnull
. While the plain text always can be converted to markup viaMarkupOutputFormat.escapePlainText(String)
, it's up to the implementation if it wants to do that now and store the markup, or later on demand (like each time whenCommonMarkupOutputFormat.getMarkupString(CommonTemplateMarkupOutputModel)
is called).
-