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();
}
Aggregations