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

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


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

      // Get directive.
      SoyJsSrcPrintDirective directive = soyJsSrcDirectivesMap.get(directiveNode.getName());
      if (directive == null) {
        throw SoySyntaxExceptionUtils.createWithNode(
            "Failed to find SoyJsSrcPrintDirective with name '" + directiveNode.getName() + "'" +
                " (tag " + node.toSourceString() + ")",
            directiveNode);
      }

      // Get directive args.
      List<ExprRootNode<?>> args = directiveNode.getArgs();
      if (! directive.getValidArgsSizes().contains(args.size())) {
        throw SoySyntaxExceptionUtils.createWithNode(
            "Print directive '" + directiveNode.getName() + "' used with the wrong number of" +
                " arguments (tag " + node.toSourceString() + ").",
            directiveNode);
      }

      // Translate directive args.
      List<JsExpr> argsJsExprs = Lists.newArrayListWithCapacity(args.size());
      for (ExprRootNode<?> arg : args) {
        argsJsExprs.add(jsExprTranslator.translateToJsExpr(arg, null, localVarTranslations));
      }

      // Apply directive.
      jsExpr = directive.applyForJsSrc(jsExpr, argsJsExprs);
    }

    jsExprs.add(jsExpr);
  }
View Full Code Here


    JsExpr result = new JsExpr(callExprText, Integer.MAX_VALUE);

    // In strict mode, escaping directives may apply to the call site.
    for (String directiveName : callNode.getEscapingDirectiveNames()) {
      SoyJsSrcPrintDirective directive = soyJsSrcDirectivesMap.get(directiveName);
      Preconditions.checkNotNull(directive,
          "Contextual autoescaping produced a bogus directive: " + directiveName);
      result = directive.applyForJsSrc(result, ImmutableList.<JsExpr>of());
    }

    return result;
  }
View Full Code Here

TOP

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

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.