use of com.google.template.soy.data.restricted.UndefinedData in project closure-templates by google.
the class EvalVisitor method visitProtoInitNode.
@Override
protected SoyValue visitProtoInitNode(ProtoInitNode node) {
// The downcast is safe because if it was anything else, compilation would have already failed.
SoyProtoType soyProto = (SoyProtoType) node.getType();
ImmutableList<String> paramNames = node.getParamNames();
SoyProtoValueImpl.Builder builder = new SoyProtoValueImpl.Builder(soyProto.getDescriptor());
for (int i = 0; i < node.numChildren(); i++) {
SoyValue visit = visit(node.getChild(i));
// null means don't assign
if (visit instanceof NullData || visit instanceof UndefinedData) {
continue;
}
builder.setField(paramNames.get(i), visit);
}
return builder.build();
}
use of com.google.template.soy.data.restricted.UndefinedData in project closure-templates by google.
the class RenderVisitor method visitPrintNode.
@Override
protected void visitPrintNode(PrintNode node) {
SoyValue result = eval(node.getExpr(), node);
if (result instanceof UndefinedData) {
throw RenderException.createWithSource("In 'print' tag, expression \"" + node.getExpr().toSourceString() + "\" evaluates to undefined.", node);
}
// Process directives.
for (PrintDirectiveNode directiveNode : node.getChildren()) {
// Evaluate directive args.
List<ExprRootNode> argsExprs = directiveNode.getArgs();
List<SoyValue> argsSoyDatas = Lists.newArrayListWithCapacity(argsExprs.size());
for (ExprRootNode argExpr : argsExprs) {
argsSoyDatas.add(eval(argExpr, directiveNode));
}
// Apply directive.
result = applyDirective(directiveNode.getPrintDirective(), result, argsSoyDatas, node);
}
append(currOutputBuf, result, node);
}
Aggregations