LordZardeck
LordZardeck

Reputation: 8283

Django render template within a template

I want to create a template for a component that is used many times on a single page, with very few changes (simply 2 or 3 variables). How can I create this template and render it within another template?

Upvotes: 12

Views: 7145

Answers (2)

neoascetic
neoascetic

Reputation: 2546

How about include?

Like so:

{% include "name_snippet.html" with person="Jane" greeting="Hello" %}

Upvotes: 23

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798476

We usually create a custom inclusion tag for this.

Upvotes: 4

Related Questions