简体   繁体   中英

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?

How about include ?

Like so:

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

We usually create a custom inclusion tag for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM