Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be an appropriate equivalent of Jinja's macros in Django's templating system?

Let's just say that I need to render a certain amount of HTML over and over in a page, for example, for a user's profile information. Jinja's macros seem like they're absolutely fit for such usage. However, Django doesn't have macros.

Right now, I'm using a custom filter for the same purpose - is this the best way to go about it, or am I missing something?

Thanks.


ps. I'm migrating an app that ran on GAE with webapp2 & Jinja to Django.

like image 614
aviraldg Avatar asked Mar 19 '12 13:03

aviraldg


1 Answers

After some more mucking with the documentation, I finally found the "correct" way to do this: custom inclusion tags, which let you create a tag out of a template.

like image 63
aviraldg Avatar answered Sep 17 '22 23:09

aviraldg