use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class MinFunction method computeForJsSrc.
@Override
public JsExpr computeForJsSrc(List<JsExpr> args) {
JsExpr arg0 = args.get(0);
JsExpr arg1 = args.get(1);
return new JsExpr("Math.min(" + arg0.getText() + ", " + arg1.getText() + ")", Integer.MAX_VALUE);
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class IsNonnullFunction method computeForJsSrc.
@Override
public JsExpr computeForJsSrc(List<JsExpr> args) {
JsExpr arg = args.get(0);
JsExpr nullJsExpr = new JsExpr("null", Integer.MAX_VALUE);
// Note: In JavaScript, "x != null" is equivalent to "x !== undefined && x !== null".
return SoyJsPluginUtils.genJsExprUsingSoySyntax(Operator.NOT_EQUAL, Lists.<JsExpr>newArrayList(arg, nullJsExpr));
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class V1JsExprTranslatorTest method runTestHelper.
private static void runTestHelper(String soyExpr, String expectedJsExpr) {
JsExpr actualJsExpr = V1JsExprTranslator.translateToJsExpr(soyExpr, SourceLocation.UNKNOWN, SoyToJsVariableMappings.startingWith(LOCAL_VAR_TRANSLATIONS), ErrorReporter.exploding());
assertThat(actualJsExpr.getText()).isEqualTo("(" + expectedJsExpr + ")");
assertThat(actualJsExpr.getPrecedence()).isEqualTo(Integer.MAX_VALUE);
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class VeLogFunctionTest method testComputeForJsSrc.
@Test
public void testComputeForJsSrc() {
VeLogFunction function = VeLogFunction.INSTANCE;
JsExpr idExpr = new JsExpr("1", Integer.MAX_VALUE);
JsExpr dataExpr = new JsExpr("null", Integer.MAX_VALUE);
assertThat(function.computeForJsSrc(ImmutableList.of(idExpr, dataExpr))).isEqualTo(new JsExpr("soy.velog.$$getLoggingAttribute('1', null, false)", Integer.MAX_VALUE));
}
Aggregations