Search in sources :

Example 1 with ReferenceScanner

use of com.squarespace.template.ReferenceScanner in project template-compiler by Squarespace.

the class TemplateC method stats.

/**
 * Scan the compiled template and print statistics.
 */
protected int stats(String templatePath, boolean preprocess) throws CodeException, IOException {
    String template = readFile(templatePath);
    CompiledTemplate compiled = compiler().compile(template, false, preprocess);
    ReferenceScanner scanner = new ReferenceScanner();
    scanner.extract(compiled.code());
    ObjectNode report = scanner.references().report();
    String result = GeneralUtils.jsonPretty(report);
    System.out.println(result);
    return 0;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ReferenceScanner(com.squarespace.template.ReferenceScanner) CompiledTemplate(com.squarespace.template.CompiledTemplate)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 CompiledTemplate (com.squarespace.template.CompiledTemplate)1 ReferenceScanner (com.squarespace.template.ReferenceScanner)1