use of com.google.template.soy.base.internal.SanitizedContentKind in project closure-templates by google.
the class LazyClosureCompiler method asRawTextOnly.
private Optional<Expression> asRawTextOnly(RenderUnitNode renderUnit) {
StringBuilder builder = null;
for (StandaloneNode child : renderUnit.getChildren()) {
if (child instanceof RawTextNode) {
if (builder == null) {
builder = new StringBuilder();
}
builder.append(((RawTextNode) child).getRawText());
} else {
return Optional.absent();
}
}
// TODO(lukes): ideally this would be a static final StringData field rather than reboxing each
// time, but we don't (yet) have a good mechanism for that.
SanitizedContentKind kind = renderUnit.getContentKind();
Expression constant = constant(builder == null ? "" : builder.toString(), parentVariables);
if (kind == null) {
return Optional.<Expression>of(MethodRef.STRING_DATA_FOR_VALUE.invoke(constant));
} else {
return Optional.<Expression>of(MethodRef.ORDAIN_AS_SAFE.invoke(constant, constantSanitizedContentKindAsContentKind(kind)));
}
}
use of com.google.template.soy.base.internal.SanitizedContentKind in project closure-templates by google.
the class HtmlContextVisitor method visitTemplateNode.
@Override
protected void visitTemplateNode(TemplateNode node) {
checkState(stateStack.isEmpty());
SanitizedContentKind contentKind = node.getContentKind();
pushState(contextForKind(contentKind));
visitChildren(node);
popState();
checkState(stateStack.isEmpty());
}
Aggregations