public final class CodeChunkUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static CodeChunk.WithValue |
concatChunks(List<? extends CodeChunk.WithValue> chunks)
Builds a
CodeChunk.WithValue that represents the concatenation of the given code
chunks. |
static CodeChunk.WithValue |
concatChunksForceString(List<? extends CodeChunk.WithValue> chunks)
Builds a
CodeChunk.WithValue that represents the concatenation of the given code
chunks. |
public static CodeChunk.WithValue concatChunks(List<? extends CodeChunk.WithValue> chunks)
CodeChunk.WithValue that represents the concatenation of the given code
chunks. The + operator is used for concatenation.
The resulting chunk is not guaranteed to be string-valued if the first two operands do not produce strings when combined with the plus operator; e.g. 2+2 might be 4 instead of '22'.
This is a port of JsExprUtils.concatJsExprs(java.util.List<? extends com.google.template.soy.jssrc.restricted.JsExpr>), which should eventually go away.
TODO(user): make that go away.
public static CodeChunk.WithValue concatChunksForceString(List<? extends CodeChunk.WithValue> chunks)
CodeChunk.WithValue that represents the concatenation of the given code
chunks. This doesn't assume the values represented by the inputs are necessarily strings, but
guarantees that the value represented by the output is a string.