Building a template engine from Scratch
summary
Builds a small compiled template engine that works: templates parse into tokens, produce JavaScript code, and become reusable render functions created with vm.runInContext. Language supports variable injections, if/elif/else branches, loops, and scoped globals; example site is a narf-powered to‑do app. The project claims zero external npm packages, tokenization via regex split, code-builder markers for insertion, and the demo generates correct HTML and multiple renders from one compiled template.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:38What is a template engine
- 4:22Template language spec
- 7:10Tokenizing the language
- 8:57Compiling to JavaScript
- 12:44Key components
- 17:57Strings to functions
- 19:22Live demo
- 21:53Summary
related talks
07mAndrey Sumin at RIT++ 2012
48mBuild your own Svelte
31mJavaScript Compilers For Fun and Profit
32mBuilding a High Performance JavaScript Compiler
18mWhy JS is Coming to Ember Templates
38mBuilding a Framework for the Edge
37mCode Generation For Everyone and Everywhere
20mSecrets of the DOM Virtual Machine
