Class ConsoleTemplateValidator
java.lang.Object
org.apache.juneau.console.freemarker.ConsoleTemplateValidator
Static lint for console FreeMarker templates. Scans each template for console directive calls and reports unknown
directives, unknown attributes, dangling template references, duplicate nav and card ids, non-strict booleans,
removed card types and globals, a chart card whose ECharts WebJar is missing (E-70), and a wrong
<@main/> count, without rendering any page.
The attribute sets are the same ones the directives enforce at render time. Interpolated values
(visible="${x}") and unquoted expressions (visible=flag) are skipped; the render-time errors cover
them. Macros defined in the template, in literally <#include>d templates and in the
chrome template are in scope, as are <@ns.x> calls on an
<#import … as ns> namespace.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne lint finding. -
Method Summary
Modifier and TypeMethodDescriptionallowDirective(String name) chromeTemplate(String name) classpathRoot(String prefix) static ConsoleTemplateValidatorcreate()templateRoot(Path dir) Lints every*.ftlhand*.ftlfile under the template root.
-
Method Details
-
create
- Returns:
- A new validator with no roots.
-
templateRoot
- Parameters:
dir- The file-system directory templates are resolved against andvalidateAll()walks.- Returns:
- This object.
-
classpathRoot
- Parameters:
prefix- The classpath prefix templates are resolved against when not found under the template root, for example"/templates/".- Returns:
- This object.
-
chromeTemplate
- Parameters:
name- The chrome template the<@page>directive renders. Its macros are in scope for every template.- Returns:
- This object.
-
allowDirective
- Parameters:
name- An adopter-defined directive or macro name to accept, for example"pageHero".- Returns:
- This object.
-
validate
- Parameters:
templateName- The template to lint, relative to the template root or classpath root.- Returns:
- The findings, sorted by line and column. Empty when the template is clean.
- Throws:
IllegalArgumentException- If the template cannot be found.
-
validateAll
Lints every*.ftlhand*.ftlfile under the template root.- Returns:
- The findings, sorted by template, line and column. Empty when every template is clean.
- Throws:
IllegalStateException- If no template root is set.
-