public final class SoyFileSet extends Object
Note: Soy file (or resource) contents must be encoded in UTF-8.
| Modifier and Type | Class and Description |
|---|---|
static class |
SoyFileSet.Builder
Builder for a
SoyFileSet. |
| Modifier and Type | Method and Description |
|---|---|
static SoyFileSet.Builder |
builder()
Creates a builder with the standard set of Soy directives, functions, and types.
|
SoyTofu |
compileToJavaObj()
Deprecated.
Use
compileToTofu(). |
List<String> |
compileToJsSrc(SoyJsSrcOptions jsSrcOptions,
SoyMsgBundle msgBundle)
Compiles this Soy file set into JS source code files and returns these JS files as a list of
strings, one per file.
|
SoyTofu |
compileToTofu()
Compiles this Soy file set into a Java object (type
SoyTofu) capable of rendering the
compiled templates. |
SoyTofu |
compileToTofu(SoyTofuOptions tofuOptions)
Compiles this Soy file set into a Java object (type
SoyTofu) capable of rendering the
compiled templates. |
SoyMsgBundle |
extractMsgs()
Extracts all messages from this Soy file set into a SoyMsgBundle (which can then be turned
into an extracted messages file with the help of a SoyMsgBundleHandler).
|
TemplateRegistry |
generateTemplateRegistry()
Parses the templates in this file set and generates a template registry.
|
SoyMsgBundle |
pruneTranslatedMsgs(SoyMsgBundle origTransMsgBundle)
Prunes messages from a given message bundle, keeping only messages used in this Soy file set.
|
public static SoyFileSet.Builder builder()
If you need additional directives, functions, or types, create the Builder instance using Guice. If your project doesn't otherwise use Guice, you can just use Guice.createInjector with only the modules you need, similar to the implementation of this method.
public TemplateRegistry generateTemplateRegistry()
SoySyntaxException - if the templates in this file set cannot be parsed according to
SyntaxVersion.V2_0.public SoyMsgBundle extractMsgs() throws SoySyntaxException
SoySyntaxException - If a syntax error is found.public SoyMsgBundle pruneTranslatedMsgs(SoyMsgBundle origTransMsgBundle) throws SoySyntaxException
Important: Do not use directly. This is subject to change and your code will break.
Note: This method memoizes intermediate results to improve efficiency in the case that it is called multiple times (which is a common case). Thus, this method will not work correctly if the underlying Soy files are modified between calls to this method.
origTransMsgBundle - The message bundle to prune.SoySyntaxExceptionpublic SoyTofu compileToTofu() throws SoySyntaxException
SoyTofu) capable of rendering the
compiled templates. The resulting SoyTofu does not cache intermediate results after
substitutions from the SoyMsgBundle and the SoyCssRenamingMap.SoyTofu object.SoySyntaxException - If a syntax error is found.compileToTofu(com.google.template.soy.tofu.SoyTofuOptions)public SoyTofu compileToTofu(SoyTofuOptions tofuOptions) throws SoySyntaxException
SoyTofu) capable of rendering the
compiled templates.tofuOptions - The compilation options for the Tofu backend.SoyTofu object.SoySyntaxException - If a syntax error is found.
TODO(brndn): Instead of throwing, should return a structure with a list of errors that callers
can inspect.@Deprecated public SoyTofu compileToJavaObj() throws SoySyntaxException
compileToTofu().SoyTofu) capable of rendering the
compiled templates. The resulting SoyTofu does not cache intermediate results after
substitutions from the SoyMsgBundle and the SoyCssRenamingMap.SoySyntaxException - If a syntax error is found.compileToTofu()public List<String> compileToJsSrc(SoyJsSrcOptions jsSrcOptions, @Nullable SoyMsgBundle msgBundle) throws SoySyntaxException
jsSrcOptions - The compilation options for the JS Src output target.msgBundle - The bundle of translated messages, or null to use the messages from the Soy
source.SoySyntaxException - If a syntax error is found.
TODO(brndn): Instead of throwing, should return a structure with a list of errors that callers
can inspect.