com.google.template.soy.tofu
Interface SoyTofu.Renderer

Enclosing interface:
SoyTofu

public static interface SoyTofu.Renderer

Renderer for a template.


Method Summary
 String render()
          Renders the template using the data, injected data, and message bundle previously set.
 void render(Appendable out)
          Renders the template using the data, injected data, and message bundle previously set into the given Appendable.
 SanitizedContent renderAsSanitizedContent()
          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 setActiveDelegatePackageNames(Set<String> activeDelegatePackageNames)
          Sets the set of active delegate package names.
 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(SoyMapData data)
          Sets the data to call the template with.
 SoyTofu.Renderer setDontAddToCache(boolean dontAddToCache)
          If set to true, indicates that we should not add the current combination of SoyMsgBundle and SoyCssRenamingMap to the cache if it's not already there.
 SoyTofu.Renderer setIjData(Map<String,?> ijData)
          Sets the injected data to call the template with.
 SoyTofu.Renderer setIjData(SoyMapData 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.
 

Method Detail

setData

SoyTofu.Renderer setData(Map<String,?> data)
Sets the data to call the template with. Can be null if the template has no parameters.

Note: If you call this method instead of setData(SoyMapData), 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 SoyMapData object and reuse it with setData(SoyMapData).


setData

SoyTofu.Renderer setData(SoyMapData data)
Sets the data to call the template with. Can be null if the template has no parameters.


setIjData

SoyTofu.Renderer setIjData(Map<String,?> ijData)
Sets the injected data to call the template with. Can be null if not used.

Note: If you call this method instead of setIjData(SoyMapData), the 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 SoyMapData object and reuse it with setIjData(SoyMapData).


setIjData

SoyTofu.Renderer setIjData(SoyMapData ijData)
Sets the injected data to call the template with. Can be null if not used.


setActiveDelegatePackageNames

SoyTofu.Renderer setActiveDelegatePackageNames(Set<String> activeDelegatePackageNames)
Sets the set of active delegate package names.


setMsgBundle

SoyTofu.Renderer setMsgBundle(SoyMsgBundle msgBundle)
Sets the bundle of translated messages, or null to use the messages from the Soy source.


setCssRenamingMap

SoyTofu.Renderer setCssRenamingMap(SoyCssRenamingMap cssRenamingMap)
Sets the CSS renaming map.


setDontAddToCache

SoyTofu.Renderer setDontAddToCache(boolean dontAddToCache)
If set to true, indicates that we should not add the current combination of SoyMsgBundle and SoyCssRenamingMap to the cache if it's not already there. Only applicable when the associated SoyTofu instance uses caching. Default value is false, i.e. by default we always add to cache when not already present.

Specifically, if dontAddToCache is set to true, then after checking the cache for the current combination of SoyMsgBundle and SoyCssRenamingMap: (a) if found in cache, we will use the cached intermediate results for faster rendering, (b) if not found in cache, we will fall back to the no-caching method of rendering.

If your app uses many different SoyMsgBundles or SoyCssRenamingMaps and you're finding that the caching mode of SoyTofu is using too much memory, one strategy may be to first prime the cache with the most common combinations by calling SoyTofu.addToCache(com.google.template.soy.msgs.SoyMsgBundle, com.google.template.soy.shared.SoyCssRenamingMap), and then when rendering, always setDontAddToCache(true). This way, most of your renders will use the cached results, yet your cache will never grow beyond the size that you initially primed it to be.


render

String render()
Renders the template using the data, injected data, and message bundle previously set.


renderAsSanitizedContent

SanitizedContent renderAsSanitizedContent()
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. Strict-autoescaped templates will return a SanitizedContent object corresponding to the kind="..." attribute of the template.

Throws:
IllegalArgumentException - If the template is non-strict.

render

void render(Appendable out)
Renders the template using the data, injected data, and message bundle previously set into the given Appendable.