Search in sources :

Example 6 with CallNode

use of com.google.template.soy.soytree.CallNode in project closure-templates by google.

the class GenCallCodeUtilsTest method getCallExprTextHelper.

private static String getCallExprTextHelper(String callSource, ImmutableList<String> escapingDirectives) {
    SoyFileSetNode soyTree = SoyFileSetParserBuilder.forTemplateContents(callSource).parse().fileSet();
    CallNode callNode = (CallNode) SharedTestUtils.getNode(soyTree, 0);
    // Manually setting the escaping directives.
    ImmutableMap<String, ? extends SoyPrintDirective> directives = INJECTOR.getInstance(new Key<ImmutableMap<String, ? extends SoyPrintDirective>>() {
    });
    callNode.setEscapingDirectives(escapingDirectives.stream().map(directives::get).collect(toImmutableList()));
    GenCallCodeUtils genCallCodeUtils = JsSrcTestUtils.createGenCallCodeUtils();
    UniqueNameGenerator nameGenerator = JsSrcNameGenerators.forLocalVariables();
    CodeChunk call = genCallCodeUtils.gen(callNode, AliasUtils.IDENTITY_ALIASES, TranslationContext.of(SoyToJsVariableMappings.forNewTemplate(), CodeChunk.Generator.create(nameGenerator), nameGenerator), ErrorReporter.exploding());
    return call.getCode();
}
Also used : SoyPrintDirective(com.google.template.soy.shared.restricted.SoyPrintDirective) CodeChunk(com.google.template.soy.jssrc.dsl.CodeChunk) SoyFileSetNode(com.google.template.soy.soytree.SoyFileSetNode) CallNode(com.google.template.soy.soytree.CallNode) UniqueNameGenerator(com.google.template.soy.base.internal.UniqueNameGenerator) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

CallNode (com.google.template.soy.soytree.CallNode)6 MsgHtmlTagNode (com.google.template.soy.soytree.MsgHtmlTagNode)3 CodeChunk (com.google.template.soy.jssrc.dsl.CodeChunk)2 MsgPlaceholderNode (com.google.template.soy.soytree.MsgPlaceholderNode)2 PrintNode (com.google.template.soy.soytree.PrintNode)2 RawTextNode (com.google.template.soy.soytree.RawTextNode)2 StandaloneNode (com.google.template.soy.soytree.SoyNode.StandaloneNode)2 TemplateNode (com.google.template.soy.soytree.TemplateNode)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 UniqueNameGenerator (com.google.template.soy.base.internal.UniqueNameGenerator)1 Statement (com.google.template.soy.jbcsrc.restricted.Statement)1 PyExpr (com.google.template.soy.pysrc.restricted.PyExpr)1 PyStringExpr (com.google.template.soy.pysrc.restricted.PyStringExpr)1 SoyPrintDirective (com.google.template.soy.shared.restricted.SoyPrintDirective)1 AbstractParentSoyNode (com.google.template.soy.soytree.AbstractParentSoyNode)1 CallParamContentNode (com.google.template.soy.soytree.CallParamContentNode)1 CallParamNode (com.google.template.soy.soytree.CallParamNode)1 MsgPluralNode (com.google.template.soy.soytree.MsgPluralNode)1