Package com.google.template.soy.jssrc.restricted

Examples of com.google.template.soy.jssrc.restricted.JsExpr


  }


  public void testApplyForJsSrc() {

    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    assertEquals(
        "soy.$$bidiUnicodeWrap(1, opt_data.myKey)",
        BIDI_UNICODE_WRAP_DIRECTIVE_FOR_STATIC_LTR.applyForJsSrc(
            dataRef, ImmutableList.<JsExpr>of()).getText());
    assertEquals(
View Full Code Here



  public void testComputeForJsSrc() {

    assertEquals(
        new JsExpr("'left'", Integer.MAX_VALUE),
        BIDI_START_EDGE_FUNCTION_FOR_STATIC_LTR.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("'right'", Integer.MAX_VALUE),
        BIDI_START_EDGE_FUNCTION_FOR_STATIC_RTL.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("(IS_RTL?-1:1) < 0 ? 'right' : 'left'", Operator.CONDITIONAL.getPrecedence()),
        BIDI_START_EDGE_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJsSrc(
            ImmutableList.<JsExpr>of()));
  }
View Full Code Here


  public void testApplyForJsSrc() {

    TextDirective textDirective = new TextDirective();
    JsExpr jsExpr = new JsExpr("whatever", Integer.MAX_VALUE);
    assertEquals(
        "'' + whatever",
        textDirective.applyForJsSrc(jsExpr, ImmutableList.<JsExpr>of()).getText());
  }
View Full Code Here

  }


  public void testComputeForJsSrc() {

    JsExpr textExpr = new JsExpr("TEXT_JS_CODE", Integer.MAX_VALUE);
    assertEquals(new JsExpr("soy.$$bidiDirAttr(1, TEXT_JS_CODE)", Integer.MAX_VALUE),
                 BIDI_DIR_ATTR_FUNCTION_FOR_STATIC_LTR.computeForJsSrc(ImmutableList.of(textExpr)));
    assertEquals(new JsExpr("soy.$$bidiDirAttr(IS_RTL?-1:1, TEXT_JS_CODE)", Integer.MAX_VALUE),
                 BIDI_DIR_ATTR_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJsSrc(
                     ImmutableList.of(textExpr)));

    JsExpr isHtmlExpr = new JsExpr("IS_HTML_JS_CODE", Integer.MAX_VALUE);
    assertEquals(new JsExpr("soy.$$bidiDirAttr(-1, TEXT_JS_CODE, IS_HTML_JS_CODE)",
                            Integer.MAX_VALUE),
                 BIDI_DIR_ATTR_FUNCTION_FOR_STATIC_RTL.computeForJsSrc(
                     ImmutableList.of(textExpr, isHtmlExpr)));
    assertEquals(new JsExpr("soy.$$bidiDirAttr(IS_RTL?-1:1, TEXT_JS_CODE, IS_HTML_JS_CODE)",
                            Integer.MAX_VALUE),
                 BIDI_DIR_ATTR_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJsSrc(
                     ImmutableList.of(textExpr, isHtmlExpr)));
  }
View Full Code Here


  public void testApplyForJsSrc() {

    InsertWordBreaksDirective insertWordBreaksDirective = new InsertWordBreaksDirective();
    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    JsExpr arg = new JsExpr("8", Integer.MAX_VALUE);
    assertEquals(
        "soy.$$insertWordBreaks(opt_data.myKey, 8)",
        insertWordBreaksDirective.applyForJsSrc(dataRef, ImmutableList.of(arg)).getText());
  }
View Full Code Here


  public void testApplyForJsSrc() {

    TruncateDirective truncateDirective = new TruncateDirective();
    JsExpr dataRefJsExpr = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    JsExpr maxLenJsExpr = new JsExpr("8", Integer.MAX_VALUE);
    JsExpr trueJsExpr = new JsExpr("true", Integer.MAX_VALUE);
    JsExpr falseJsExpr = new JsExpr("false", Integer.MAX_VALUE);
    assertEquals(
        "soy.$$truncate(opt_data.myKey, 8, true)",
        truncateDirective.applyForJsSrc(dataRefJsExpr, ImmutableList.of(maxLenJsExpr)).getText());
    assertEquals(
        "soy.$$truncate(opt_data.myKey, 8, true)",
View Full Code Here

  public void testComputeForJsSrc() {

    BidiTextDirFunction bidiTextDirFunction = new BidiTextDirFunction();

    JsExpr textExpr = new JsExpr("TEXT_JS_CODE", Integer.MAX_VALUE);
    assertEquals(new JsExpr("soy.$$bidiTextDir(TEXT_JS_CODE)", Integer.MAX_VALUE),
                 bidiTextDirFunction.computeForJsSrc(ImmutableList.of(textExpr)));

    JsExpr isHtmlExpr = new JsExpr("IS_HTML_JS_CODE", Integer.MAX_VALUE);
    assertEquals(new JsExpr("soy.$$bidiTextDir(TEXT_JS_CODE, IS_HTML_JS_CODE)", Integer.MAX_VALUE),
                 bidiTextDirFunction.computeForJsSrc(
                     ImmutableList.of(textExpr, isHtmlExpr)));
  }
View Full Code Here


  public void testComputeForJsSrc() {

    assertEquals(
        new JsExpr("'\\u200E'", Integer.MAX_VALUE),
        BIDI_MARK_FUNCTION_FOR_STATIC_LTR.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("'\\u200F'", Integer.MAX_VALUE),
        BIDI_MARK_FUNCTION_FOR_STATIC_RTL.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("(IS_RTL?-1:1) < 0 ? '\\u200F' : '\\u200E'",
                   Operator.CONDITIONAL.getPrecedence()),
        BIDI_MARK_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJsSrc(ImmutableList.<JsExpr>of()));
  }
View Full Code Here


  public void testApplyForJsSrc() {

    ChangeNewlineToBrDirective directive = new ChangeNewlineToBrDirective();
    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    assertEquals("soy.$$changeNewlineToBr(opt_data.myKey)",
                 directive.applyForJsSrc(dataRef, ImmutableList.<JsExpr>of()).getText());
  }
View Full Code Here


  public void testComputeForJsSrc() {

    assertEquals(
        new JsExpr("'right'", Integer.MAX_VALUE),
        BIDI_END_EDGE_FUNCTION_FOR_STATIC_LTR.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("'left'", Integer.MAX_VALUE),
        BIDI_END_EDGE_FUNCTION_FOR_STATIC_RTL.computeForJsSrc(ImmutableList.<JsExpr>of()));
    assertEquals(
        new JsExpr("(IS_RTL?-1:1) < 0 ? 'left' : 'right'", Operator.CONDITIONAL.getPrecedence()),
        BIDI_END_EDGE_FUNCTION_FOR_ISRTL_CODE_SNIPPET.computeForJsSrc(ImmutableList.<JsExpr>of()));
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.jssrc.restricted.JsExpr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.