Class CombinedMarkupOutputFormat
- Since:
- 2.3.24
-
Constructor Summary
ConstructorsConstructorDescriptionCombinedMarkupOutputFormat(MarkupOutputFormat outer, MarkupOutputFormat inner)Same asCombinedMarkupOutputFormat(String, MarkupOutputFormat, MarkupOutputFormat)withnullas thenameparameter.CombinedMarkupOutputFormat(String name, MarkupOutputFormat outer, MarkupOutputFormat inner) -
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#ftlheader).booleanTells if by default auto-escaping should be on for this format.booleanisLegacyBuiltInBypassed(String builtInName)Tells if a string built-in that can't handle aTemplateMarkupOutputModelleft hand operand can bypass this object as is.booleanTells if this output format allows insertingTemplateMarkupOutputModel-s of another output formats into it.protected TemplateCombinedMarkupOutputModelnewTemplateMarkupOutputModel(String plainTextContent, String markupContent)Creates a newCommonTemplateMarkupOutputModelthat's bound to thisOutputFormatinstance.voidEquivalent to callingMarkupOutputFormat.fromPlainTextByEscaping(String)and thenMarkupOutputFormat.output(TemplateMarkupOutputModel, Writer), but the implementation may use a more efficient solution.<MO2 extends TemplateMarkupOutputModel<MO2>>
voidoutputForeign(MO2 mo, Writer out)Outputs a value from a foreign output format; only used ifOutputFormat.isOutputFormatMixingAllowed()returntrue.Methods inherited from class freemarker.core.CommonMarkupOutputFormat
concat, fromMarkup, fromPlainTextByEscaping, getMarkupString, getSourcePlainText, isEmpty, outputMethods inherited from class freemarker.core.OutputFormat
toString, toStringExtraProperties
-
Constructor Details
-
CombinedMarkupOutputFormat
Same asCombinedMarkupOutputFormat(String, MarkupOutputFormat, MarkupOutputFormat)withnullas thenameparameter. -
CombinedMarkupOutputFormat
- Parameters:
name- Maybenull, in which case it defaults toouter.getName() + "{" + inner.getName() + "}".
-
-
Method Details
-
getName
Description copied from class:OutputFormatThe short name used to refer to this format (like in the#ftlheader).- Specified by:
getNamein classOutputFormat
-
getMimeType
Description copied from class:OutputFormatReturns the MIME type of the output format. This might comes handy when generating a HTTP response.nullnullif this output format doesn't clearly corresponds to a specific MIME type.- Specified by:
getMimeTypein classOutputFormat
-
output
Description copied from class:MarkupOutputFormatEquivalent to callingMarkupOutputFormat.fromPlainTextByEscaping(String)and thenMarkupOutputFormat.output(TemplateMarkupOutputModel, Writer), but the implementation may use a more efficient solution.- Specified by:
outputin classCommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- Throws:
IOExceptionTemplateModelException
-
outputForeign
public <MO2 extends TemplateMarkupOutputModel<MO2>> void outputForeign(MO2 mo, Writer out) throws IOException, TemplateModelExceptionDescription copied from class:MarkupOutputFormatOutputs a value from a foreign output format; only used ifOutputFormat.isOutputFormatMixingAllowed()returntrue. The default implementation inMarkupOutputFormatwill just let the otherOutputFormatto output value, but it can be overridden to support more nuanced conversions, or to check if outputting without conversion should be allowed.- Overrides:
outputForeignin classMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- Throws:
IOExceptionTemplateModelException
-
escapePlainText
Description copied from class:MarkupOutputFormatShould give the same result asMarkupOutputFormat.fromPlainTextByEscaping(String)and thenMarkupOutputFormat.getMarkupString(TemplateMarkupOutputModel), but the implementation may use a more efficient solution.- Specified by:
escapePlainTextin classMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- Throws:
TemplateModelException
-
isLegacyBuiltInBypassed
Description copied from class:MarkupOutputFormatTells if a string built-in that can't handle aTemplateMarkupOutputModelleft hand operand can bypass this object as is. A typical such case would be when aTemplateHTMLOutputModelof "HTML" format bypasses?html.- Specified by:
isLegacyBuiltInBypassedin classMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- Throws:
TemplateModelException
-
isAutoEscapedByDefault
public boolean isAutoEscapedByDefault()Description copied from class:MarkupOutputFormatTells if by default auto-escaping should be on for this format. It should betrueif you need to escape on most of the places where you insert values.- Overrides:
isAutoEscapedByDefaultin classCommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- See Also:
Configuration.setAutoEscapingPolicy(int)
-
isOutputFormatMixingAllowed
public boolean isOutputFormatMixingAllowed()Description copied from class:OutputFormatTells if this output format allows insertingTemplateMarkupOutputModel-s of another output formats into it.If
true, the foreignTemplateMarkupOutputModelwill be inserted into the output. If the current output format is aMarkupOutputFormatthis is done using theMarkupOutputFormat.outputForeign(TemplateMarkupOutputModel, Writer)method, which can implement smart conversions. The default behavior (and the only behavior for non-markup outputs) is to behave as if the surrounding output format was the same; this is usually a bad idea to allow, as such an event could indicate application bugs.If this method returns
false(recommended), then FreeMarker will try to assimilate the inserted value by converting its format to this format, which will currently (2.3.24) cause exception, unless the inserted value is made by escaping plain text and the target format is non-escaping, in which case format conversion is trivially possible. (It's not impossible that conversions will be extended beyond this, if there will be demand for that.)truevalue is used byUndefinedOutputFormat.- Overrides:
isOutputFormatMixingAllowedin classCommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel>
-
getOuterOutputFormat
-
getInnerOutputFormat
-
newTemplateMarkupOutputModel
protected TemplateCombinedMarkupOutputModel newTemplateMarkupOutputModel(String plainTextContent, String markupContent)Description copied from class:CommonMarkupOutputFormatCreates a newCommonTemplateMarkupOutputModelthat's bound to thisOutputFormatinstance. When this is called fromCommonMarkupOutputFormat, exactly one of the parameters will be non-null.- Specified by:
newTemplateMarkupOutputModelin classCommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel>- Parameters:
plainTextContent-nullif the content is markup that possibly can be described as plain text without loss.markupContent- Typically will benullifplainTextContentis 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).
-