NEW TICKET#42 · Email templates
Email templates with fallbacks and escaping
Kwame Mensah · Designer
Opened today
“Studios write their own reminder emails with placeholders: {{ name }}, or {{ name | there }} with a fallback after the bar. Spaces inside the braces are allowed. A value that is missing, null or an empty string uses the fallback, or nothing if there isn't one. A real value is always used, 0 included: "You owe 0" is correct. Values come from client records, so escape them for HTML (escapeHtml is written below); the fallback is the studio's own text and isn't escaped. The pattern is written. Can you finish fillTemplate?”
YOUR PLAN
- 1Watch an example2 min
- 2Warm-up 11 min
- 3Warm-up 21 min
- 4Fix the ticket31 min
BY THE END YOU CAN
- Replace matches with a function
- Tell a missing value apart from a falsy one
- Escape untrusted text before it goes into HTML