Correct me if I'm wrong, but can't jinja be pretty much used as a direct
drop in for django?
Ben

On 22/01/2008, Jeff Anderson <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I stress again that I don't know a ton about the django template system,
> (or any for that matter)
> That being said, I will proceed to say what I think I know:
>
> I don't believe that there is a macro-like feature in the django
> template system that could do that. You'd have to switch completely to
> jinja in order to get that functionality. I know that isn't what you
> want to hear.
> It sounds like that it would be a useful feature...
>
> <pause for searching for a ticket>
>
> In my handful of searches, I couldn't find an open ticket for such a
> feature. You could create one to suggest it.
> It would be something I could learn to use in my templates, given it was
> available.
>
> Good luck!
>
> Jeff Anderson
>
> [EMAIL PROTECTED] wrote:
> > 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
> >>
> >
> > > >
> >
>
>
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447503145951

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to