Training attendance notice
Type on the left - the preview on the right updates with real data from the chosen record. Click a field in the list to insert it at the cursor.
How it works
DocTemplateEngine.parse(body)turns each line into a block:Heading,Text,TableBlock,Tag... (Java 21sealed interface+records).fill()replaces{{key}}with a regex; unknown keys show as[?key].- The same blocks are rendered twice:
toHtml()for this preview (aswitchwith pattern matching) andtoPdf()with OpenPDF for printing. - The data map is built from SQL Server in
TemplateService.context().
for (Block b : blocks) {
switch (b) {
case Heading h -> doc.add(para(fill(h.text(), ctx), Fonts.bold(18), ALIGN_LEFT, 6));
case TableBlock t -> doc.add(tablePdf(t, ctx));
case Tag t -> tagPdf(doc, t, ctx, barcodes); // [[lines]], [[qr:...]] ...
...
}
}
Files: service/DocTemplateEngine.java, service/TemplateService.java, web/TemplateController.java.