BuildMidBackendAuto-graded
Build a prompt renderer that resists template injection
Support placeholders, #if blocks and #each loops, and print variable values literally even when they look like template code.Your team writes the prompt templates. The variables that fill them often come from users, retrieved documents or tool output. Implementrender(template, vars) in engine.py with {{ name }} placeholders, an {{#if key}} block and an {{#each list}} loop. A value that contains template syntax, such as {{secret}} or {{/if}}, has to appear in the output exactly as written. The full spec is at the top of the file, and the current version doesn't meet it yet.35 min
Python
Goals
- An
{{#if key}}block shows its contents only when the key is present and truthy. - An
{{#each list}}block repeats its body once per item, with{{ this }}as the current item. - Template syntax inside a variable value comes out as plain text and is never expanded.
- A placeholder with no matching variable renders as an empty string, with no error.
What it measures
Prompt engineeringKeeping the trusted template apart from the untrusted values that fill it.
Context engineeringAssembling prompts from optional sections and repeated items.
Injection awarenessTreating every substituted value as untrusted input that may carry template syntax.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
35 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo