Search in sources :

Example 16 with JsExpr

use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.

the class ChangeNewlineToBrDirectiveTest method testApplyForJsSrc.

@Test
public void testApplyForJsSrc() {
    ChangeNewlineToBrDirective directive = new ChangeNewlineToBrDirective();
    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    assertThat(directive.applyForJsSrc(dataRef, ImmutableList.<JsExpr>of()).getText()).isEqualTo("soy.$$changeNewlineToBr(opt_data.myKey)");
}
Also used : JsExpr(com.google.template.soy.jssrc.restricted.JsExpr) Test(org.junit.Test)

Example 17 with JsExpr

use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.

the class FilterImageDataUriDirectiveTest method testApplyForJsSrc.

@Test
public void testApplyForJsSrc() {
    FilterImageDataUriDirective cleanHtml = new FilterImageDataUriDirective();
    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    assertThat(cleanHtml.applyForJsSrc(dataRef, ImmutableList.<JsExpr>of()).getText()).isEqualTo("soy.$$filterImageDataUri(opt_data.myKey)");
}
Also used : JsExpr(com.google.template.soy.jssrc.restricted.JsExpr) Test(org.junit.Test)

Example 18 with JsExpr

use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.

the class AugmentMapFunctionTest method testComputeForJsSrc.

@Test
public void testComputeForJsSrc() {
    AugmentMapFunction augmentMapFunction = new AugmentMapFunction();
    JsExpr baseMapExpr = new JsExpr("BASE_MAP_JS_CODE", Integer.MAX_VALUE);
    JsExpr additionalMapExpr = new JsExpr("ADDITIONAL_MAP_JS_CODE", Integer.MAX_VALUE);
    assertThat(augmentMapFunction.computeForJsSrc(ImmutableList.of(baseMapExpr, additionalMapExpr))).isEqualTo(new JsExpr("soy.$$augmentMap(BASE_MAP_JS_CODE, ADDITIONAL_MAP_JS_CODE)", Integer.MAX_VALUE));
}
Also used : JsExpr(com.google.template.soy.jssrc.restricted.JsExpr) Test(org.junit.Test)

Example 19 with JsExpr

use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.

the class BidiTextDirFunction method computeForJsSrc.

@Override
public JsExpr computeForJsSrc(List<JsExpr> args) {
    JsExpr value = args.get(0);
    JsExpr isHtml = (args.size() == 2) ? args.get(1) : null;
    String callText = (isHtml != null) ? "soy.$$bidiTextDir(" + value.getText() + ", " + isHtml.getText() + ")" : "soy.$$bidiTextDir(" + value.getText() + ")";
    return new JsExpr(callText, Integer.MAX_VALUE);
}
Also used : JsExpr(com.google.template.soy.jssrc.restricted.JsExpr)

Example 20 with JsExpr

use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.

the class BidiMarkAfterFunction method computeForJsSrc.

@Override
public JsExpr computeForJsSrc(List<JsExpr> args) {
    JsExpr value = args.get(0);
    JsExpr isHtml = (args.size() == 2) ? args.get(1) : null;
    String callText = "soy.$$bidiMarkAfter(" + bidiGlobalDirProvider.get().getCodeSnippet() + ", " + value.getText() + (isHtml != null ? ", " + isHtml.getText() : "") + ")";
    return new JsExpr(callText, Integer.MAX_VALUE);
}
Also used : JsExpr(com.google.template.soy.jssrc.restricted.JsExpr)

Aggregations

JsExpr (com.google.template.soy.jssrc.restricted.JsExpr)64 Test (org.junit.Test)42 CodeChunk (com.google.template.soy.jssrc.dsl.CodeChunk)3 ImmutableList (com.google.common.collect.ImmutableList)2 RequiresCollector (com.google.template.soy.jssrc.dsl.CodeChunk.RequiresCollector)2 SoyLibraryAssistedJsSrcPrintDirective (com.google.template.soy.jssrc.restricted.SoyLibraryAssistedJsSrcPrintDirective)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 SanitizedContent (com.google.template.soy.data.SanitizedContent)1 ContentKind (com.google.template.soy.data.SanitizedContent.ContentKind)1 SoyValue (com.google.template.soy.data.SoyValue)1 UnsafeSanitizedContentOrdainer (com.google.template.soy.data.UnsafeSanitizedContentOrdainer)1 SoyString (com.google.template.soy.data.restricted.SoyString)1 StringData (com.google.template.soy.data.restricted.StringData)1 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)1 StringNode (com.google.template.soy.exprtree.StringNode)1 WithValue (com.google.template.soy.jssrc.dsl.CodeChunk.WithValue)1 SoyJsSrcPrintDirective (com.google.template.soy.jssrc.restricted.SoyJsSrcPrintDirective)1