Generating output.
WHAT A TEMPLATE IS
A page with placeholders, filled with values when rendered.
WHY USE ONE
Separates presentation from logic Prevents building markup by joining strings
WHY THAT SECOND POINT MATTERS
Joining strings to build pages is how content gets interpreted as markup.
WHAT TEMPLATES PROVIDE
Inserting values, escaped Conditions and loops Reusable layout
WHAT TO PUT IN A TEMPLATE
Presentation only.
WHAT TO KEEP OUT
Business logic Database access Complex calculation
WHY
Logic in templates cannot be tested and is hard to find.
WHAT TO USE FOR SHARED STRUCTURE
A base layout that pages extend.
WHAT TO CHECK
That escaping is on by default Where you have deliberately disabled it, and why
THAT LAST POINT
Disabling escaping for a value is occasionally necessary and always worth a comment.
WHAT TO AVOID
Marking user-supplied content as safe.