# Flask Templating Jinja

> Mastering server-side rendering with Jinja2 layouts, macros, and filters.

- Skill: `jcorpac/flask-templating-jinja` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jcorpac/flask-templating-jinja`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jcorpac/flask-templating-jinja/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jcorpac (https://skillmd.com/u/jcorpac)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/jcorpac/flask-templating-jinja

---


# Flask Templating (Jinja2)

The front-end begins with the server. Jinja2 provides the power to build dynamic, reusable HTML.

## Pattern & Inheritance
- **Base Layout**: Use `base.html` for common headers, footers, and styles.
- **Block Inheritance**: Use `{% block content %}` to allow child templates to inject their specific content.

## Reusability
- **Macros**: Like functions for HTML (e.g., a reusable button or form field).
- **Includes**: Component-level reusability for navigation bars or sidebars.

## Logic & Context
- **Control Flow**: `{% if user.is_authenticated %}`, `{% for item in items %}`.
- **Filters**: Formatting data directly in the template (e.g., `{{ date|format_date }}`).

## Best Practices
- **Never Render Raw HTML**: Ensure variables are escaped to prevent XSS.
- **Logic Placement**: Keep complex calculations in Python, and only use templating for display logic.


