Skip to content

Build a Template Engine

Build a Jinja2-style template engine: tokenize {{ var }} and {% tag %}, parse to AST, resolve variables, apply filters with auto-escaping, evaluate if/for control flow, and implement template inheritance with extends/block. Powers Flask, Ansible, Salt, Helm.

intermediate10 lessons4 chapters10 graded exercisesPython

No sign-up needed for lesson 1 · certificate on completion · sign up to save progress

What you’ll have built

Chapter by chapter. Every step is a graded exercise.

  • Lexing & Parsing
  • Variables & Filters
  • Control Flow
  • Inheritance & Production
Starts in Python — solve in the language you choose in the editor, same tests either way.

Curriculum

4 chapters, 10 lessons. Each lesson is a short read, one graded exercise, and a quiz.

  1. 1What Template Engines SolveRead · exercise · quiz
  2. 2Tokenizing TemplatesRead · exercise · quiz
  3. 3Parsing to ASTRead · exercise · quiz
Loading reference solution…