
One Jinja2 template, 147 calculator pages — here's the architecture
Last month someone on Dev.to asked how many templates I use for my calculator pages. When I said "one" they thought I was joking. I'm not. One Jinja2 template renders 147 different calculator pages. BMI calculators, unit converters, loan estimators, percentage tools — all the same HTML file. Here's the pattern that makes it work. The problem with 147 separate files Imagine this: you want to change the layout of your calculator result section. With 147 separate template files, that's 147 edits. Miss one and now your kilometers-to-miles converter has a different layout than everything else. And good luck catching that in code review. I learned this the painful way. My first 20 calculators each had their own template. By calculator 21, I was copy-pasting so much that I introduced 3 different bugs from stale HTML. Something had to change. The architecture (4 layers) The whole pattern comes down to four layers: URL request → Route handler → Data config → Universal template → Page Let me wal
Continue reading on Dev.to Webdev
Opens in a new tab


