jinja2
- Repo stars 2,412
- License NOASSERTION
- Author repo debugpy
Skill: Jinja2
Best practices for template rendering with Jinja2 including environments, filters, autoescaping, and security.
When to Use
Apply this skill when rendering templates with Jinja2 — HTML pages, emails, configuration files, and code generation.
Environment
- Create a
jinja2.Environment(loader=..., autoescape=...)once and reuse it. - Use
FileSystemLoaderfor file-based templates,PackageLoaderfor installed packages. - Enable
autoescape=Truefor HTML templates to prevent XSS.
Templates
- Use
{{ variable }}for output,{% if/for/block %}for control flow. - Use template inheritance (
{% extends 'base.html' %}) for layout reuse. - Define custom filters for reusable transformations.
Security
- Always enable
autoescape=Truewhen rendering HTML. - Use
SandboxedEnvironmentfor untrusted templates. - Never render user input as template code — only as template data.
- Use
|efilter explicitly when autoescape is off.
Pitfalls
- Don't use
Template(string)directly — it bypasses the environment's loader and settings. - Watch for undefined variable errors — use
undefined=StrictUndefinedduring development. - Avoid complex logic in templates — keep them focused on presentation.
- Fluxly category
- Other
- Author-declared agents
- No explicit declaration found; this is not inferred or tested compatibility
- Static check
- 94 / 100 · heuristic scan, not runtime safety proof
- Author / version / license
- @microsoft · NOASSERTION
- Fluxly token estimate
- Lean
- Fluxly setup estimate
- Plug-and-play
- External API key
- No requirement detected
- Detected OS requirements
- Unspecified
- Runtime requirements
- Unspecified
- Detected file/system behavior
-
- Read-only
- Write / modify
- Detected network behavior
- Local-only
- Install commands
- None (reference only)
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
The current SKILL.md does not define a fixed output example. Apply this skill when rendering templates with Jinja2 — HTML pages, emails, configuration files, and code generation.
Create a jinja2.Environment(loader=..., autoescape=...) once and reuse it. Use FileSystemLoader for file-based templates, PackageLoader for installed packages. Enable autoescape=True for HTML templates to prevent XSS.
Use {{ variable }} for output, {% if/for/block %} for control flow. Use template inheritance ({% extends 'base.html' %}) for layout reuse. Define custom filters for reusable transformations.
Always enable autoescape=True when rendering HTML. Use SandboxedEnvironment for untrusted templates. Never render user input as template code — only as template data.
Don't use Template(string) directly — it bypasses the environment's loader and settings. Watch for undefined variable errors — use undefined=StrictUndefined during development. Avoid complex logic in templates — keep them focused on presentation.
# Skill: Jinja2
Best practices for template rendering with Jinja2 including environments, filters, autoescaping, and security.
## When to Use
Apply this skill when rendering templates with Jinja2 — HTML pages, emails, configuration files, and code generation.
## Environment
- Create a `jinja2.Environment(loader=..., autoescape=...)` once and reuse it.
- Use `FileSystemLoader` for file-based templates, `PackageLoader` for installed packages.
- Enable `autoescape=True` for HTML templates to prevent XSS.
## Templates
- Use `{{ variable }}` for output, `{% if/for/block %}` for control flow.
- Use template inheritance (`{% extends 'base.html' %}`) for layout reuse.
- Define custom filters for reusable transformations.
## Security
- **Always** enable `autoescape=True` when rendering HTML.
- Use `SandboxedEnvironment` for untrusted templates.
- Never render user input as template code — only as template data.
- Use `|e` filter explicitly when autoescape is off.
## Pitfalls
- Don't use `Template(string)` directly — it bypasses the environment's loader and settings.
- Watch for undefined variable errors — use `undefined=StrictUndefined` during development.
- Avoid complex logic in templates — keep them focused on presentation. Author text anchors workflow facts; Fluxly only indexes current sections, terms, files, and commands.
sections -> When to Use → Environment → Templates → Security → Pitfalls
terms -> Always · Best practices for template rendering with Jinja2 including environments, filters, autoescaping, and security. · Apply this skill when rendering templates with Jinja2 — HTML pages, emails, configuration files, and code generation. · - Create a jinja2.Environment(loader=..., autoescape=...) once and reuse it. · - Use {{ variable }} for output, {% if/for/block %} for control flow. · - Always enable autoescape=True when rendering HTML. · - Don't use Template(string) directly — it bypasses the environment's loader and settings.
files/cmd -> jinja2.Environment(loader=..., autoescape=...) · FileSystemLoader · PackageLoader · autoescape=True · {{ variable }} · {% if/for/block %} · {% extends 'base.html' %} · SandboxedEnvironment
body sha256 -> 3ace875bcc67
Decide Fit First
Design Intent
How To Use It
Boundaries And Review