public static final class SoyFileSet.Builder extends Object
SoyFileSet
.Constructor and Description |
---|
Builder()
Deprecated.
Use the static SoyFileSet.builder() method, or inject SoyFileSet.Builder
using Guice with SoyModule installed. The behavior of this builder is unpredictable and
will use the Soy configuration from the most recently configured Injector containing a
SoyModule, because it relies on Guice's static injection.
|
Modifier and Type | Method and Description |
---|---|
SoyFileSet.Builder |
add(CharSequence content,
String filePath)
Adds an input Soy file, given the file content provided as a string, as well as the desired
file path for messages.
|
SoyFileSet.Builder |
add(com.google.common.io.CharSource contentSource,
String filePath)
Adds an input Soy file, given a
CharSource for the file content, as well as the
desired file path for messages. |
SoyFileSet.Builder |
add(File inputFile)
Adds an input Soy file, given a
File . |
SoyFileSet.Builder |
add(URL inputFileUrl)
Adds an input Soy file, given a resource
URL . |
SoyFileSet.Builder |
add(URL inputFileUrl,
String filePath)
Adds an input Soy file, given a resource
URL , as well as the desired file path for
messages. |
SoyFileSet.Builder |
addVolatile(File inputFile)
Adds an input Soy file that supports checking for modifications, given a
File . |
SoyFileSet.Builder |
addVolatileWithKind(File inputFile,
SoyFileKind soyFileKind)
Adds an input Soy file that supports checking for modifications, given a
File . |
SoyFileSet.Builder |
addWithKind(CharSequence content,
SoyFileKind soyFileKind,
String filePath)
Adds an input Soy file, given the file content provided as a string, as well as the desired
file path for messages.
|
SoyFileSet.Builder |
addWithKind(com.google.common.io.CharSource contentSource,
SoyFileKind soyFileKind,
String filePath)
Adds an input Soy file, given a
CharSource for the file content, as well as the
desired file path for messages. |
SoyFileSet.Builder |
addWithKind(File inputFile,
SoyFileKind soyFileKind)
Adds an input Soy file, given a
File . |
SoyFileSet.Builder |
addWithKind(URL inputFileUrl,
SoyFileKind soyFileKind)
Adds an input Soy file, given a resource
URL . |
SoyFileSet.Builder |
addWithKind(URL inputFileUrl,
SoyFileKind soyFileKind,
String filePath)
Adds an input Soy file, given a resource
URL , as well as the desired file path for
messages. |
SoyFileSet |
build()
Builds the new
SoyFileSet . |
SoyFileSet.Builder |
setAllowExternalCalls(boolean allowExternalCalls)
Sets whether to allow external calls (calls to undefined templates).
|
SoyFileSet.Builder |
setCompileTimeGlobals(File compileTimeGlobalsFile)
Sets the file containing compile-time globals.
|
SoyFileSet.Builder |
setCompileTimeGlobals(Map<String,?> compileTimeGlobalsMap)
Sets the map from compile-time global name to value.
|
SoyFileSet.Builder |
setCompileTimeGlobals(URL compileTimeGlobalsResource)
Sets the resource file containing compile-time globals.
|
SoyFileSet.Builder |
setCssHandlingScheme(SoyGeneralOptions.CssHandlingScheme cssHandlingScheme)
Sets the scheme for handling
css commands. |
SoyFileSet.Builder |
setDeclaredSyntaxVersionName(String versionName)
Sets the user-declared syntax version name for the Soy file bundle.
|
void |
setGeneralOptions(SoyGeneralOptions generalOptions)
Sets all Soy general options.
|
SoyFileSet.Builder |
setLocalTypeRegistry(SoyTypeRegistry typeRegistry)
Override the global type registry with one that is local to this file set.
|
SoyFileSet.Builder |
setSoyAstCache(SoyAstCache cache)
Configures to use an AST cache to speed up development time.
|
SoyFileSet.Builder |
setStrictAutoescapingRequired(boolean strictAutoescapingRequired)
Sets whether to force strict autoescaping.
|
SoyFileSet.Builder |
setSupportContentSecurityPolicy(boolean supportContentSecurityPolicy)
Pass true to enable CSP (Content Security Policy) support which adds an extra pass that marks
inline scripts in templates specially so the browser can distinguish scripts written by
trusted template authors from scripts injected via XSS.
|
@Inject @Deprecated public Builder()
public void setGeneralOptions(SoyGeneralOptions generalOptions)
This must be called before any other setters.
public SoyFileSet build()
SoyFileSet
.SoyFileSet
.public SoyFileSet.Builder addWithKind(com.google.common.io.CharSource contentSource, SoyFileKind soyFileKind, String filePath)
CharSource
for the file content, as well as the
desired file path for messages.contentSource
- Source for the Soy file content.soyFileKind
- The kind of this input Soy file.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder add(com.google.common.io.CharSource contentSource, String filePath)
CharSource
for the file content, as well as the
desired file path for messages.contentSource
- Source for the Soy file content.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder addWithKind(File inputFile, SoyFileKind soyFileKind)
File
.inputFile
- The Soy file.soyFileKind
- The kind of this input Soy file.public SoyFileSet.Builder add(File inputFile)
File
.inputFile
- The Soy file.public SoyFileSet.Builder addVolatileWithKind(File inputFile, SoyFileKind soyFileKind)
File
.
Note: This does nothing by itself. It should be used in conjunction with a feature that
actually checks for volatile files. Currently, that feature is
setSoyAstCache(SoyAstCache)
.
inputFile
- The Soy file.soyFileKind
- The kind of this input Soy file.public SoyFileSet.Builder addVolatile(File inputFile)
File
.
Note: This does nothing by itself. It should be used in conjunction with a feature that
actually checks for volatile files. Currently, that feature is
setSoyAstCache(SoyAstCache)
.
inputFile
- The Soy file.public SoyFileSet.Builder addWithKind(URL inputFileUrl, SoyFileKind soyFileKind, String filePath)
URL
, as well as the desired file path for
messages.inputFileUrl
- The Soy file.soyFileKind
- The kind of this input Soy file.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder add(URL inputFileUrl, String filePath)
URL
, as well as the desired file path for
messages.inputFileUrl
- The Soy file.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder addWithKind(URL inputFileUrl, SoyFileKind soyFileKind)
URL
.
Important: This function assumes that the desired file path is returned by
inputFileUrl.toString()
. If this is not the case, please use
addWithKind(URL, SoyFileKind, String)
instead.
inputFileUrl
- The Soy file.soyFileKind
- The kind of this input Soy file.addWithKind(URL, SoyFileKind, String)
public SoyFileSet.Builder add(URL inputFileUrl)
URL
.
Important: This function assumes that the desired file path is returned by
inputFileUrl.toString()
. If this is not the case, please use
add(URL, String)
instead.
inputFileUrl
- The Soy file.add(URL, String)
public SoyFileSet.Builder addWithKind(CharSequence content, SoyFileKind soyFileKind, String filePath)
content
- The Soy file content.soyFileKind
- The kind of this input Soy file.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder add(CharSequence content, String filePath)
content
- The Soy file content.filePath
- The path to the Soy file (used for messages only).public SoyFileSet.Builder setSoyAstCache(SoyAstCache cache)
This is undesirable in production mode since it uses strictly more memory, and this only helps if the same templates are going to be recompiled frequently.
cache
- The cache to use, which can have a lifecycle independent of the SoyFileSet.
Null indicates not to use a cache.public SoyFileSet.Builder setDeclaredSyntaxVersionName(@Nonnull String versionName)
versionName
- The syntax version name, e.g. "1.0", "2.0", "2.3".public SoyFileSet.Builder setAllowExternalCalls(boolean allowExternalCalls)
allowExternalCalls
- Whether to allow external calls (calls to undefined templates).public SoyFileSet.Builder setStrictAutoescapingRequired(boolean strictAutoescapingRequired)
strictAutoescapingRequired
- Whether strict autoescaping is required.public SoyFileSet.Builder setCssHandlingScheme(SoyGeneralOptions.CssHandlingScheme cssHandlingScheme)
css
commands.cssHandlingScheme
- The scheme for handling css
commands.public SoyFileSet.Builder setCompileTimeGlobals(Map<String,?> compileTimeGlobalsMap)
The values can be any of the Soy primitive types: null, boolean, integer, float (Java double), or string.
compileTimeGlobalsMap
- Map from compile-time global name to value. The values can be
any of the Soy primitive types: null, boolean, integer, float (Java double), or string.SoySyntaxException
- If one of the values is not a valid Soy primitive type.public SoyFileSet.Builder setCompileTimeGlobals(File compileTimeGlobalsFile) throws IOException
Each line of the file should have the format
<global_name> = <primitive_data>where primitive_data is a valid Soy expression literal for a primitive type (null, boolean, integer, float, or string). Empty lines and lines beginning with "//" are ignored. The file should be encoded in UTF-8.
If you need to generate a file in this format from Java, consider using the utility
SoyUtils.generateCompileTimeGlobalsFile()
.
compileTimeGlobalsFile
- The file containing compile-time globals.IOException
- If there is an error reading the compile-time globals file.public SoyFileSet.Builder setCompileTimeGlobals(URL compileTimeGlobalsResource) throws IOException
Each line of the file should have the format
<global_name> = <primitive_data>where primitive_data is a valid Soy expression literal for a primitive type (null, boolean, integer, float, or string). Empty lines and lines beginning with "//" are ignored. The file should be encoded in UTF-8.
If you need to generate a file in this format from Java, consider using the utility
SoyUtils.generateCompileTimeGlobalsFile()
.
compileTimeGlobalsResource
- The resource containing compile-time globals.IOException
- If there is an error reading the compile-time globals file.public SoyFileSet.Builder setSupportContentSecurityPolicy(boolean supportContentSecurityPolicy)
Scripts are marked using a per-page-render secret stored in the injected variable
$ij.csp_nonce
.
Scripts in non-contextually auto-escaped templates may not be found.
public SoyFileSet.Builder setLocalTypeRegistry(SoyTypeRegistry typeRegistry)