public interface SoyTofu
Important: If you're a user of Soy, you should use the methods here (on a SoyTofu object created by Soy), but should not create your own implementations of this interface.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SoyTofu.Renderer
Renderer for a template.
|
| Modifier and Type | Method and Description |
|---|---|
SoyTofu |
forNamespace(String namespace)
Gets a new SoyTofu instance with a different namespace (or no namespace).
|
String |
getNamespace()
Gets the namespace of this SoyTofu object.
|
com.google.common.collect.ImmutableSortedSet<String> |
getUsedIjParamsForTemplate(SoyTemplateInfo templateInfo)
Gets the set of injected param keys used by a template (and its transitive callees).
|
com.google.common.collect.ImmutableSortedSet<String> |
getUsedIjParamsForTemplate(String templateName)
Gets the set of injected param keys used by a template (and its transitive callees).
|
SoyTofu.Renderer |
newRenderer(SoyTemplateInfo templateInfo)
Gets a new Renderer for a template.
|
SoyTofu.Renderer |
newRenderer(String templateName)
Gets a new Renderer for a template.
|
String |
render(SoyTemplateInfo templateInfo,
SoyRecord data,
SoyMsgBundle msgBundle)
Deprecated.
|
String |
render(String templateName,
Map<String,?> data,
SoyMsgBundle msgBundle)
Deprecated.
Use
newRenderer(String). |
String |
render(String templateName,
SoyRecord data,
SoyMsgBundle msgBundle)
Deprecated.
Use
newRenderer(String). |
String getNamespace()
newRenderer() to be called with a partial template name (e.g. ".fooTemplate").
Note: The namespace may be null, in which case newRenderer() must be called with the
full template name.SoyTofu forNamespace(@Nullable String namespace)
namespace - The namespace for the new SoyTofu instance, or null for no namespace.SoyTofu.Renderer newRenderer(SoyTemplateInfo templateInfo)
The usage pattern is soyTofu.newRenderer(...).setData(...).setInjectedData(...).setMsgBundle(...).render() where any of the set* parts can be omitted if it's null.
templateInfo - Info for the template to render.SoyTofu.Renderer newRenderer(String templateName)
The usage pattern is soyTofu.newRenderer(...).setData(...).setInjectedData(...).setMsgBundle(...).render() where any of the set* parts can be omitted if it's null.
templateName - The name of the template to render. If this SoyTofu instance is not
namespaced, then this parameter should be the full name of the template including the
namespace. If this SoyTofu instance is namespaced, then this parameter should be a partial
name beginning with a dot (e.g. ".fooTemplate").com.google.common.collect.ImmutableSortedSet<String> getUsedIjParamsForTemplate(SoyTemplateInfo templateInfo)
Note: The SoyTemplateInfo object already has a method getUsedIjParams().
That method should produce the same results as this method, unless the bundle of Soy files
included when running the SoyParseInfoGenerator is different from the bundle of Soy files
included when creating this SoyTofu object.
templateInfo - Info for the template to get injected params of.com.google.common.collect.ImmutableSortedSet<String> getUsedIjParamsForTemplate(String templateName)
templateName - The name of the template to get injected params of.@Deprecated String render(SoyTemplateInfo templateInfo, @Nullable SoyRecord data, @Nullable SoyMsgBundle msgBundle)
newRenderer(SoyTemplateInfo).templateInfo - Info for the template to render.data - The data to call the template with. Can be null if the template has no parameters.msgBundle - The bundle of translated messages, or null to use the messages from the
Soy source.@Deprecated String render(String templateName, @Nullable Map<String,?> data, @Nullable SoyMsgBundle msgBundle)
newRenderer(String). Note: If you call this method instead of render(String, SoyRecord, SoyMsgBundle),
your template 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 render(String, SoyRecord, SoyMsgBundle).
templateName - The name of the template to render. If this SoyTofu instance is namespaced,
then this parameter should be a partial name beginning with a dot (e.g. ".fooTemplate").data - The data to call the template with. Can be null if the template has no parameters.msgBundle - The bundle of translated messages, or null to use the messages from the
Soy source.@Deprecated String render(String templateName, @Nullable SoyRecord data, @Nullable SoyMsgBundle msgBundle)
newRenderer(String).templateName - The name of the template to render. If this SoyTofu instance is namespaced,
then this parameter should be a partial name beginning with a dot (e.g. ".fooTemplate").data - The data to call the template with. Can be null if the template has no parameters.msgBundle - The bundle of translated messages, or null to use the messages from the
Soy source.