use of com.google.template.soy.soytree.CallParamValueNode in project closure-templates by google.
the class SoyNodeCompiler method prepareParamsHelper.
private Expression prepareParamsHelper(CallNode node, Label reattachPoint) {
if (node.numChildren() == 0) {
// Easy, just use the data attribute
return getDataExpression(node, reattachPoint);
} else {
// Otherwise we need to build a dictionary from {param} statements.
Expression paramStoreExpression = getParamStoreExpression(node, reattachPoint);
for (CallParamNode child : node.getChildren()) {
String paramKey = child.getKey().identifier();
Expression valueExpr;
if (child instanceof CallParamContentNode) {
valueExpr = lazyClosureCompiler.compileLazyContent("param", (CallParamContentNode) child, paramKey);
} else {
valueExpr = lazyClosureCompiler.compileLazyExpression("param", child, paramKey, ((CallParamValueNode) child).getExpr());
}
// ParamStore.setField return 'this' so we can just chain the invocations together.
paramStoreExpression = MethodRef.PARAM_STORE_SET_FIELD.invoke(paramStoreExpression, BytecodeUtils.constant(paramKey), valueExpr);
}
return paramStoreExpression;
}
}
Aggregations