Examples of JsExpr


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

    exprText = JsSrcUtils.escapeUnicodeFormatChars(exprText);
    // Note: </script> in a JavaScript string will end the current script tag
    // in most browsers.  Escape the forward slash in the string to get around
    // this issue.
    exprText = exprText.replace("</script>", "<\\/script>");
    jsExprs.add(new JsExpr(exprText, Integer.MAX_VALUE));
  }
View Full Code Here

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

   * <pre>
   *   MSG_UNNAMED_42
   * </pre>
   */
  @Override protected void visitGoogMsgRefNode(GoogMsgRefNode node) {
    jsExprs.add(new JsExpr(node.getRenderedGoogMsgVarName(), Integer.MAX_VALUE));
  }
View Full Code Here

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

   *   gooData4.moo + 5
   * </pre>
   */
  @Override protected void visitPrintNode(PrintNode node) {

    JsExpr jsExpr = jsExprTranslator.translateToJsExpr(
        node.getExprUnion().getExpr(), node.getExprText(), localVarTranslations);

    // Process directives.
    for (PrintDirectiveNode directiveNode : node.getChildren()) {

View Full Code Here

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

    StringBuilder sb = new StringBuilder();
    sb.append("goog.getCssName(");

    ExprRootNode<?> componentNameExpr = node.getComponentNameExpr();
    if (componentNameExpr != null) {
      JsExpr baseJsExpr = jsExprTranslator.translateToJsExpr(
          componentNameExpr, node.getComponentNameText(), localVarTranslations);
      sb.append(baseJsExpr.getText()).append(", ");
    }

    sb.append('\'').append(node.getSelectorText()).append("')");

    jsExprs.add(new JsExpr(sb.toString(), Integer.MAX_VALUE));
  }
View Full Code Here

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

    }
  }


  @Override public JsExpr computeForJsSrc(List<JsExpr> args) {
    JsExpr arg = args.get(0);

    return new JsExpr("Math.floor(" + arg.getText() + ")", Integer.MAX_VALUE);
  }
View Full Code Here

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

    for (SoyNode child : node.getChildren()) {

      if (child instanceof IfCondNode) {
        IfCondNode icn = (IfCondNode) child;

        JsExpr condJsExpr = jsExprTranslator.translateToJsExpr(
            icn.getExprUnion().getExpr(), icn.getExprText(), localVarTranslations);
        jsExprTextSb.append('(').append(condJsExpr.getText()).append(") ? ");

        List<JsExpr> condBlockJsExprs = genJsExprsVisitor.exec(icn);
        jsExprTextSb.append(JsExprUtils.concatJsExprs(condBlockJsExprs).getText());

        jsExprTextSb.append(" : ");

      } else if (child instanceof IfElseNode) {
        hasElse = true;
        IfElseNode ien = (IfElseNode) child;

        List<JsExpr> elseBlockJsExprs = genJsExprsVisitor.exec(ien);
        jsExprTextSb.append(JsExprUtils.concatJsExprs(elseBlockJsExprs).getText());

      } else {
        throw new AssertionError();
      }
    }

    if (!hasElse) {
      jsExprTextSb.append("''");
    }

    jsExprs.add(new JsExpr(jsExprTextSb.toString(), Operator.CONDITIONAL.getPrecedence()));
  }
View Full Code Here

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

    return toSoyData(SoyBidiUtils.getBidiFormatter(bidiGlobalDir).markAfter(text, isHtml));
  }


  @Override public JsExpr computeForJsSrc(List<JsExpr> args) {
    JsExpr text = args.get(0);
    JsExpr isHtml = (args.size() == 2) ? args.get(1) : null;

    String callText =
        "soy.$$bidiMarkAfter(" + bidiGlobalDirProvider.get().getCodeSnippet() + ", " +
        text.getText() + (isHtml != null ? ", " + isHtml.getText() : "") + ")";

    return new JsExpr(callText, Integer.MAX_VALUE);
  }
View Full Code Here

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

        SanitizedContent.ContentKind.ATTRIBUTES);
  }


  @Override public JsExpr computeForJsSrc(List<JsExpr> args) {
    JsExpr text = args.get(0);
    JsExpr isHtml = (args.size() == 2) ? args.get(1) : null;

    String callText =
        "soy.$$bidiDirAttr(" + bidiGlobalDirProvider.get().getCodeSnippet() + ", " +
        text.getText() + (isHtml != null ? ", " + isHtml.getText() : "") + ")";

    return new JsExpr(callText, Integer.MAX_VALUE);
  }
View Full Code Here

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


  public void testApplyForJsSrc() {

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

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


  public void testApplyForJsSrc() {

    NoAutoescapeDirective noAutoescapeDirective = new NoAutoescapeDirective();
    JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
    assertEquals(
        "soy.$$filterNoAutoescape(opt_data.myKey)",
        noAutoescapeDirective.applyForJsSrc(dataRef, ImmutableList.<JsExpr>of()).getText());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.