Friday, June 17, 2011

Re: Helper methods like rails or taglibs/tagfiles like java

On Thu, Jun 16, 2011 at 7:03 PM, Rodrigo Gomes <rgomes@gmail.com> wrote:
> Yes, but the point is not about generate code. Is to follow a DRY
> principle...If I have a "multiple select list" with a specific
> behavior,look-and-feel, with some javascript surrounding the code, etc, I
> don't want to write this everywhere...I just want to create once and use it
> anywhere...with just a line of code...
> And I can do this easily with java through tagfiles, and sometimes taglibs.
> And now with django I'm using inclusion tag as suggested by Tom.
> The only reason that I'm not enjoying inclusion tags so much, is because I
> can not pass named parameters to them...only positional. But is works
> []'s
> Rodrigo Gomes
>

I don't normally pass any parameters; you can instead specify that it
should have the template context available to it instead, and then
pull named parameters out of there.

If the parameters that the inclusion template is expecting have
different names to the ones in the context, then I just alias them
using the {% with %} tag.

Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate