LATTE Template Engine

All examples use regular HTML or PHP syntax. I prefer to use LATTE for all my documents as it helps me to keep my templates clean and it provides many great helpers that would otherwise need additional checks.

As RockPdf relies on RockFrontend we have LATTE support out of the box 😎🚀

You don't know latte yet? Be sure to check out their website at https://latte.nette.org/de/ and also check this forum post: Why I love the Latte Template Engine.

All you have to do is load a LATTE file instead of an HTML or PHP file:

/** @var RockPdf $pdf */
$pdf = $modules->get('RockPdf');
$pdf
  ->load("/site/test.latte")
  ->save(preview: true);

Latte and mPDF tags

mPDF tags like {PAGENO} conflict with the default latte single brace syntax. Simply change the syntax to off or double:

<p n:syntax="off">Page {PAGENO}/{nb}</p>

Latte Escaping

Latte by default escapes HTML, which is a good thing when rendering HTML documents. However, if you want to use Latte for PDFs, and you want to place HTML in your PDFs, you need to use the noescape filter:

<h1>{$page->title|noescape}</h1>

Pro-Tip: You can disable the need for |noescape filter by adding {contentType text} to the first line of your LATTE file!