public final class SoyUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
generateCompileTimeGlobalsFile(Map<String,?> compileTimeGlobalsMap,
Appendable output)
Generates the text for a compile-time globals file in the format expected by the Soy compiler
and appends the generated text to the given
Appendable. |
static com.google.common.collect.ImmutableMap<String,PrimitiveData> |
parseCompileTimeGlobals(com.google.common.io.CharSource inputSource)
Parses a globals file in the format created by
generateCompileTimeGlobalsFile(java.util.Map<java.lang.String, ?>, java.lang.Appendable) into a
map from global name to primitive value. |
public static void generateCompileTimeGlobalsFile(Map<String,?> compileTimeGlobalsMap, Appendable output) throws IOException
Appendable.
The generated lines will follow the iteration order of the provided map.
Important: When you write the output to a file, be sure to use UTF-8 encoding.
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.output - The object to append the generated text to.SoySyntaxException - If one of the values is not a valid Soy primitive type.IOException - If there is an error appending to the given Appendable.public static com.google.common.collect.ImmutableMap<String,PrimitiveData> parseCompileTimeGlobals(com.google.common.io.CharSource inputSource) throws IOException
generateCompileTimeGlobalsFile(java.util.Map<java.lang.String, ?>, java.lang.Appendable) into a
map from global name to primitive value.inputSource - A source that returns a reader for the globals file.IOException - If an error occurs while reading the globals file.IllegalStateException - If the globals file is not in the correct format.