hi jeff, thanks for your response. writing tags to replace macros looks like an overkill to me. especially because a macro may hold a content that's specific to a template and such a thing naturally belongs to the template itself and shouldn't go somewhere deep into the python codebase.
have this example simplified from my app i'm where with Jinja I could have: {% macro display_person name, email %} <p><a href="mailto:{{ email }}">{{name}}</a></p> {% endmacro %} <h2>Subscribed people</h2> {% for person in persons.subscribed %} {{ display_person(person.name, person.email) }} {% endfor %} <h2>Not subscribed people</h2> {% for person in persons.notsubscribed %} {{ display_person(person.name, person.email) }} {% endfor %} having "display_person" as a template tag looks like a total overkill given the relative complexity of writing template tags. and having the simple <p><a ...></p> in a separate file for 'include' doesn't look sane either. it's just a piece of reusable html/template that logically belongs to the template itself. is there any way perhaps with 'block' tag to achieve this macro-like behaviour? thanks papa On Jan 22, 3:47 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote: > I'm no expert with any template system, but I believe you can write your > own template tags for django's template system. > > http://www.djangoproject.com/documentation/templates_python/ > > At the section called "Extending the template system" > > Hopefully this is a good starting point! > > Jeff Anderson > > Papalagi Pakeha wrote: > > hi there! > > > i wonder if there is any way to have Macros in django templates > > similar to what Jinja has (http://jinja.pocoo.org/)? > > > the closest i could get was using 'include' tag and have the > > repetitive content in a standalone file, but it's pretty obscure to > > have a separate file for each little bit of content that to be > > repeated here and there. > > > is there any other way other than switching to Jinja to get some sort > > of macros in django templates? > > > thanks > > > papa > > > > > > > signature.asc > 1KDownload --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---