Search in sources :

Example 11 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class MaxFunction method computeForJava.

@Override
public SoyValue computeForJava(List<SoyValue> args) {
    SoyValue arg0 = args.get(0);
    SoyValue arg1 = args.get(1);
    return BasicFunctionsRuntime.max(arg0, arg1);
}
Also used : SoyValue(com.google.template.soy.data.SoyValue)

Example 12 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class RandomIntFunction method computeForJava.

@Override
public SoyValue computeForJava(List<SoyValue> args) {
    SoyValue arg = args.get(0);
    long longValue = arg.longValue();
    return IntegerData.forValue(BasicFunctionsRuntime.randomInt(longValue));
}
Also used : SoyValue(com.google.template.soy.data.SoyValue)

Example 13 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class StrIndexOfFunction method computeForJava.

@Override
public SoyValue computeForJava(List<SoyValue> args) {
    SoyValue arg0 = args.get(0);
    SoyValue arg1 = args.get(1);
    Preconditions.checkArgument(arg0 instanceof SoyString, "First argument to strIndexOf() function is not StringData or SanitizedContent: %s", arg0);
    Preconditions.checkArgument(arg1 instanceof SoyString, "Second argument to strIndexOf() function is not StringData or SanitizedContent: %s", arg1);
    String strArg0 = arg0.coerceToString();
    String strArg1 = arg1.coerceToString();
    return IntegerData.forValue(strArg0.indexOf(strArg1));
}
Also used : SoyString(com.google.template.soy.data.restricted.SoyString) SoyString(com.google.template.soy.data.restricted.SoyString) SoyValue(com.google.template.soy.data.SoyValue)

Example 14 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class StrLenFunction method computeForJava.

@Override
public SoyValue computeForJava(List<SoyValue> args) {
    SoyValue arg0 = args.get(0);
    Preconditions.checkArgument(arg0 instanceof SoyString, "First argument to strLen() function is not StringData or SanitizedContent: %s", arg0);
    return IntegerData.forValue(arg0.coerceToString().length());
}
Also used : SoyString(com.google.template.soy.data.restricted.SoyString) SoyValue(com.google.template.soy.data.SoyValue)

Example 15 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class AugmentMapFunction method computeForJava.

// IntelliJ
@SuppressWarnings("ConstantConditions")
@Override
public SoyValue computeForJava(List<SoyValue> args) {
    SoyValue arg0 = args.get(0);
    SoyValue arg1 = args.get(1);
    Preconditions.checkArgument(arg0 instanceof SoyLegacyObjectMap, "First argument to augmentMap() function is not SoyLegacyObjectMap.");
    Preconditions.checkArgument(arg1 instanceof SoyLegacyObjectMap, "Second argument to augmentMap() function is not SoyLegacyObjectMap.");
    // TODO: Support map with nonstring key.
    Preconditions.checkArgument(arg0 instanceof SoyDict, "First argument to augmentMap() function is not SoyDict. Currently, augmentMap() doesn't" + " support maps that are not dicts (it is a todo).");
    Preconditions.checkArgument(arg1 instanceof SoyDict, "Second argument to augmentMap() function is not SoyDict. Currently, augmentMap() doesn't" + " support maps that are not dicts (it is a todo).");
    return BasicFunctionsRuntime.augmentMap((SoyDict) arg0, (SoyDict) arg1);
}
Also used : SoyLegacyObjectMap(com.google.template.soy.data.SoyLegacyObjectMap) SoyDict(com.google.template.soy.data.SoyDict) SoyValue(com.google.template.soy.data.SoyValue)

Aggregations

SoyValue (com.google.template.soy.data.SoyValue)61 Test (org.junit.Test)31 StringData (com.google.template.soy.data.restricted.StringData)5 ExprNode (com.google.template.soy.exprtree.ExprNode)4 SoyLegacyObjectMap (com.google.template.soy.data.SoyLegacyObjectMap)3 SoyList (com.google.template.soy.data.SoyList)3 ParentExprNode (com.google.template.soy.exprtree.ExprNode.ParentExprNode)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 SanitizedContentKind (com.google.template.soy.base.internal.SanitizedContentKind)2 SanitizedContent (com.google.template.soy.data.SanitizedContent)2 ContentKind (com.google.template.soy.data.SanitizedContent.ContentKind)2 SoyDataException (com.google.template.soy.data.SoyDataException)2 SoyDict (com.google.template.soy.data.SoyDict)2 SoyRecord (com.google.template.soy.data.SoyRecord)2 FloatData (com.google.template.soy.data.restricted.FloatData)2 IntegerData (com.google.template.soy.data.restricted.IntegerData)2 SoyString (com.google.template.soy.data.restricted.SoyString)2 UndefinedData (com.google.template.soy.data.restricted.UndefinedData)2 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)2 SoyPrintDirective (com.google.template.soy.shared.restricted.SoyPrintDirective)2