Search in sources :

Example 1 with SyntaxVersion

use of com.google.template.soy.basetree.SyntaxVersion in project closure-templates by google.

the class SoyToPySrcCompiler method compile.

@Override
void compile(SoyFileSet.Builder sfsBuilder) throws IOException {
    if (syntaxVersion.length() > 0) {
        SyntaxVersion parsedVersion = SyntaxVersion.forName(syntaxVersion);
        if (parsedVersion.num < SyntaxVersion.V2_0.num) {
            exitWithError("Declared syntax version must be 2.0 or greater.");
        }
        sfsBuilder.setDeclaredSyntaxVersionName(syntaxVersion);
    }
    // Disallow external call entirely in Python.
    sfsBuilder.setAllowExternalCalls(false);
    // Require strict templates in Python.
    sfsBuilder.setStrictAutoescapingRequired(true);
    SoyFileSet sfs = sfsBuilder.build();
    // Load the manifest if available.
    ImmutableMap<String, String> manifest = loadNamespaceManifest(namespaceManifestPaths);
    if (!manifest.isEmpty() && outputNamespaceManifest == null) {
        exitWithError("Namespace manifests provided without outputting a new manifest.");
    }
    // Create SoyPySrcOptions.
    SoyPySrcOptions pySrcOptions = new SoyPySrcOptions(runtimePath, environmentModulePath, bidiIsRtlFn, translationClass, manifest, outputNamespaceManifest);
    // Compile.
    sfs.compileToPySrcFiles(outputPathFormat, inputPrefix, pySrcOptions);
}
Also used : SyntaxVersion(com.google.template.soy.basetree.SyntaxVersion) SoyPySrcOptions(com.google.template.soy.pysrc.SoyPySrcOptions)

Example 2 with SyntaxVersion

use of com.google.template.soy.basetree.SyntaxVersion in project closure-templates by google.

the class SoyFileSet method preprocessIncrementalDOMResults.

/**
 * Prepares the parsed result for use in generating Incremental DOM source code.
 */
@SuppressWarnings("deprecation")
private ParseResult preprocessIncrementalDOMResults() {
    SyntaxVersion declaredSyntaxVersion = generalOptions.getDeclaredSyntaxVersion(SyntaxVersion.V2_0);
    Preconditions.checkState(declaredSyntaxVersion.num >= SyntaxVersion.V2_0.num, "Incremental DOM code generation only supports syntax version of V2 or higher.");
    requireStrictAutoescaping();
    // For incremental dom backend, we don't desugar HTML nodes since it requires HTML context.
    ParseResult result = parse(passManagerBuilder(SyntaxVersion.V2_0).desugarHtmlNodes(false));
    throwIfErrorsPresent();
    return result;
}
Also used : SyntaxVersion(com.google.template.soy.basetree.SyntaxVersion) ParseResult(com.google.template.soy.SoyFileSetParser.ParseResult)

Aggregations

SyntaxVersion (com.google.template.soy.basetree.SyntaxVersion)2 ParseResult (com.google.template.soy.SoyFileSetParser.ParseResult)1 SoyPySrcOptions (com.google.template.soy.pysrc.SoyPySrcOptions)1