Anvil Logo
Products
Industries
Resources
Developers

Ask Anvil

Answers to questions about automating PDFs, e-signatures, Webforms, and other paperwork problems.
Have a question? Ask us directly and we’ll answer it shortly.
PDFs
Categories

Why does my PDF template show {{variableName}} instead of the actual value?

What's happening

A literal {{tag}} in your output means the template engine didn't substitute a value. Most engines (Mustache, Handlebars, Liquid, default Jinja2) emit empty space rather than the literal tag when a data key is undefined, so a literal tag in the output usually points to a different class of bug than missing data.

Four causes, in order of how often they're the cause

  1. The template engine never ran on the file. You sent the raw template to a PDF renderer that doesn't process templates, or the template-engine step is missing from your pipeline. Confirm the engine runs before the PDF render call. If you wired up Handlebars but never invoked Handlebars.compile(template)(data), the renderer just sees text.
  2. Wrong delimiters for the engine. Most engines use {{variable}}, but a few use [[variable]], <<variable>>, or ${variable}. Tags written in the wrong syntax are just text to the engine. Confirm what your engine expects.
  3. You're looking at the unfilled template preview. Editors often display the raw template with literal tags. Confirm you're viewing the actual generated PDF returned by the render call, not the editing canvas or a saved copy of the template itself.
  4. File extension or content-type mismatch. Some template systems decide whether to process a file based on extension (.hbs, .liquid, .jinja) or content-type. Files outside those expectations are rendered as static text.

If you're on Anvil

Anvil's PDF Filling API takes a JSON data object keyed by field names defined in the template editor; the PDF Generation API expects pre-rendered HTML or Markdown. Neither endpoint does mustache-style interpolation server-side, so a literal {{variable}} arriving at either one means the substitution wasn't done client-side before the call.

A quick test

Log the template string and the data payload immediately before the engine call, then log the engine's return value. If the engine output still contains {{firstName}}, the engine didn't run or didn't recognize the syntax. If the output has empty space where the value should be, you're in missing-data territory: check that the key in your payload matches the tag exactly, including case.

Back to All Questions
Anvil Logo

The fastest way to build software for documents

Anvil Document SDK is a comprehensive toolbox for product teams launching document flows where PDF filling, signing, and complex conditional scenarios are necessary.
Explore Anvil
Anvil Webforms