Search in sources :

Example 1 with SoyPySrcOptions

use of com.google.template.soy.pysrc.SoyPySrcOptions 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)

Aggregations

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