use of com.google.template.soy.soytree.AutoescapeMode in project closure-templates by google.
the class InferenceEngine method inferTemplateEndContext.
/**
* Infer an end context for the given template and, if requested, choose escaping directives for
* any <code>{print}</code>.
*
* @param templateNode A template that is visited in {@code startContext} and no other. If a
* template can be reached from multiple contexts, then it should be cloned. This class
* automatically does that for called templates.
* @param inferences Receives all suggested changes and inferences to tn.
* @return The end context when the given template is reached from {@code startContext}.
*/
public static Context inferTemplateEndContext(TemplateNode templateNode, Context startContext, Inferences inferences, ErrorReporter errorReporter) {
Context endContext;
AutoescapeMode autoescapeMode = templateNode.getAutoescapeMode();
InferenceEngine inferenceEngine = new InferenceEngine(autoescapeMode, autoescapeMode, inferences, errorReporter);
// Context started off as startContext and we have propagated context through all of
// template's children, so now context is the template's end context.
endContext = inferenceEngine.infer(templateNode, startContext);
inferences.recordTemplateEndContext(templateNode.getTemplateName(), endContext);
return endContext;
}
use of com.google.template.soy.soytree.AutoescapeMode in project closure-templates by google.
the class StrictHtmlValidationPass method checkTemplateNode.
private void checkTemplateNode(TemplateNode node) {
AutoescapeMode autoescapeMode = node.getAutoescapeMode();
if (autoescapeMode != AutoescapeMode.STRICT && node.isStrictHtml()) {
errorReporter.report(node.getSourceLocation(), STRICT_HTML_WITHOUT_AUTOESCAPE);
return;
}
// ContentKind is guaranteed to be non-null if AutoescapeMode is strict.
SanitizedContentKind contentKind = node.getContentKind();
if (contentKind != SanitizedContentKind.HTML && node.isStrictHtml()) {
errorReporter.report(node.getSourceLocation(), STRICT_HTML_WITH_NON_HTML);
return;
}
if (node.isStrictHtml()) {
new HtmlTagVisitor(errorReporter).exec(node);
}
}
Aggregations