Package io.github.chkrishnatej.rp3200.template


package io.github.chkrishnatej.rp3200.template
Text templates for receipts: {{placeholders}} for data plus [markup] for formatting, compiled once and rendered to ESC/POS bytes.

Entry point: ReceiptTemplate. Its class documentation contains the complete placeholder and markup reference.


 ReceiptTemplate t = ReceiptTemplate.compile("""
         [center][b]{{shop}}[/b]
         {{#each items}}
         [cols *,4r,10r]{{name}}|{{qty}}|{{amount:%.2f}}
         {{/each}}
         [cut]
         """);
 byte[] bytes = t.render(Map.of("shop", "MY SHOP", "items", items));
 String text  = t.preview(Map.of("shop", "MY SHOP", "items", items));   // for tests/logs
 

Errors are reported as TemplateException with the line number and the reason.

  • Class
    Description
    A compiled receipt template: plain text with {{placeholders}} and [markup].
    Thrown when a receipt template cannot be compiled or rendered.