On Fri, 2006-06-16 at 03:24 +0000, Joseph Dickson wrote:
> Greetings..
>
> I'm considering Django as a web framework for a new project, and am
> trying to wrap my mind around how I would accomplish some things..
>
> One of the things that I need to be able to do is to have a sort of
> "macro" like ability in my templates. I have to generate a lot of
> repetitive HTML (in my case, a bunch of checkboxes). The view method
> really has no way to effectively do this in my case -- it needs to be
> in the template. (And it's just HTML generating goo, nothing fancy and
> nothing that knows anything about the rest of my app)
>
> I'd like to be able to do some sort of construct like:
>
> gen_checkboxes(start_id, end_id)
>
> where start_id and end_id are arguments that control how the checkboxes
> are generated.
>
> What is the most Django-ish way to do this? From perusing the docs, it
> seems like the only real option available to me is to code a custom
> tag, such that the construct inside the template would be like:
>
> {% gen_checkboxes start_id end_id %}
>
> Is there a more lightweight solution than this, or a better way?
That's the way to do it, yes. It's pretty lightweight, since writing
custom template tags is fairly easy. Implementing your own sort of thing
like this is not "bad" in any way.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---