Type to search. Arrow keys to move, Enter to open, Esc to close.

All technologies

Template-based document generation

Separating content (structured data) from presentation (templates), so one build step produces every version of a document from a single source.

Project requirement

Keep a CV and a cover letter in two languages and several variants without the versions drifting apart.

Technical question

How can one content source produce every language and variant, while missing translations and overlong documents are caught automatically?

Validation

A working generator builds two variants in two languages; tests cover resolution and escaping, and repeated builds give identical PDFs.

Decision

Resolve language and variant before rendering, keep templates free of logic, allow overrides only for whitelisted keys, and check the output during the build.

Resolution order: defaults, then variant, then per-document override, then command line.

Escaping depends on the output format (LaTeX or HTML), so it belongs to the rendering step, not to the content.

Implementations by language

Python

YAML data is resolved into a plain context in Python and rendered with Jinja2 into LaTeX, then compiled to PDF with latexmk.

  • Jinja2 delimiters are switched to \VAR{}, \BLOCK{} and \#{} so they do not clash with LaTeX braces.
  • Escaping runs in the Jinja2 finalize hook, so every output value is escaped and already safe text is marked to avoid double escaping.
  • A fixed SOURCE_DATE_EPOCH makes the PDF output byte-identical for the same content.

Used by projects

Related research