A checked template gives a Qute page a type-safe entry point. Declare a static class with `@CheckedTemplate`, then add a method returning `TemplateInstance` whose name matches the template file. Its parameters replace passing values through `data()`. Qute checks template usage during the build and reports invalid parameter references. section 6.2.3
To serve a reservation page:
- Declare `index(LocalDate startDate, LocalDate endDate, String name)` in the annotated class for `index.html`. section 6.2.3
- Call `Templates.index(...)` from the REST endpoint. Use `defaultName` on `@CheckedTemplate` if the file-naming convention differs; an underscored strategy maps `indexPage` to `index_page.html`. section 6.2.3
Listing 6.16 Building template instances with type safety
@CheckedTemplate
public static class Templates {
public static native TemplateInstance index(
LocalDate startDate,
LocalDate endDate,
String name);
public static native TemplateInstance listofreservations(
Collection<Reservation> reservations);
public static native TemplateInstance availablecars(
Collection<Car> cars,
LocalDate startDate,
LocalDate endDate);
}
The declarations show typed entry points for the main page, reservations, and available cars. section 6.2.3
