public static interface SoyTofu.Renderer
Important: If you're a user of Soy, you should use the methods here (on a Renderer object created by Soy), but should not create your own implementations of this interface.
| Modifier and Type | Method and Description |
|---|---|
String |
render()
Renders the template using the data, injected data, and message bundle previously set.
|
SanitizedContent.ContentKind |
render(Appendable out)
Renders the template using the data, injected data, and message bundle previously set into
the given Appendable.
|
SanitizedContent |
renderStrict()
Renders the strict-mode template as a SanitizedContent object, which can be used as an input
to another Soy template, or used to verify that the output type is correct.
|
SoyTofu.Renderer |
setActiveDelegatePackageSelector(com.google.common.base.Predicate<String> activeDelegatePackageSelector)
Sets the predicate to use for testing whether or not a given
delpackage is active. |
SoyTofu.Renderer |
setContentKind(SanitizedContent.ContentKind contentKind)
Sets the expected content kind.
|
SoyTofu.Renderer |
setCssRenamingMap(SoyCssRenamingMap cssRenamingMap)
Sets the CSS renaming map.
|
SoyTofu.Renderer |
setData(Map<String,?> data)
Sets the data to call the template with.
|
SoyTofu.Renderer |
setData(SoyRecord data)
Sets the data to call the template with.
|
SoyTofu.Renderer |
setDebugSoyTemplateInfo(boolean debugSoyTemplateInfo)
Configures if we should render additional HTML comments for runtime inspection.
|
SoyTofu.Renderer |
setIdRenamingMap(SoyIdRenamingMap idRenamingMap)
Sets the ID renaming map.
|
SoyTofu.Renderer |
setIjData(Map<String,?> ijData)
Sets the injected data to call the template with.
|
SoyTofu.Renderer |
setIjData(SoyRecord ijData)
Sets the injected data to call the template with.
|
SoyTofu.Renderer |
setMsgBundle(SoyMsgBundle msgBundle)
Sets the bundle of translated messages, or null to use the messages from the Soy source.
|
SoyTofu.Renderer setData(Map<String,?> data)
Note: If you call this method instead of setData(SoyRecord), your template data
will be converted to a SoyMapData object on each call. This may not be a big deal if
you only need to use the data object once. But if you need to reuse the same data object for
multiple calls, it's more efficient to build your own SoyRecord object and reuse it
with setData(SoyRecord).
SoyTofu.Renderer setData(SoyRecord data)
SoyTofu.Renderer setIjData(Map<String,?> ijData)
Note: If you call this method instead of setIjData(SoyRecord), the data will be
converted to a SoyRecord object on each call. This may not be a big deal if you only
need to use the data object once. But if you need to reuse the same data object for multiple
calls, it's more efficient to build your own SoyRecord object and reuse it with
setIjData(SoyRecord).
SoyTofu.Renderer setIjData(SoyRecord ijData)
SoyTofu.Renderer setActiveDelegatePackageSelector(com.google.common.base.Predicate<String> activeDelegatePackageSelector)
delpackage is active.SoyTofu.Renderer setMsgBundle(SoyMsgBundle msgBundle)
SoyTofu.Renderer setIdRenamingMap(SoyIdRenamingMap idRenamingMap)
SoyTofu.Renderer setCssRenamingMap(SoyCssRenamingMap cssRenamingMap)
SoyTofu.Renderer setDebugSoyTemplateInfo(boolean debugSoyTemplateInfo)
SoyTofu.Renderer setContentKind(SanitizedContent.ContentKind contentKind)
An attempt to render a non-strict template or a strict template with a different kind will fail if this has been called.
String render()
Checks the content kind of the template. Non-strict and kind="html" templates are allowed, unless setContentKind was called. The goal is to prevent accidental rendering of unescaped kind="text" in contexts where that could XSS.
SoyTofuException - if an error occurs during rendering.SanitizedContent renderStrict()
This returns a SanitizedContent object corresponding to the kind="..." attribute of the template. The expected content kind must be set beforehand, unless HTML is expected, to avoid an exception.
IllegalArgumentException - If the template is non-strict, or the kind doesn't match the
expected kind (from setContentKind, or the default of HTML).SoyTofuException - if an error occurs during rendering.SanitizedContent.ContentKind render(Appendable out)
Checks the content kind of the template. Non-strict and kind="html" templates are allowed, unless setContentKind was called. The goal is to prevent accidental rendering of unescaped kind="text" in contexts where that could XSS.
SoyTofuException - if an error occurs during rendering.