Hi,

This sounds really better! But I tried it and got an error.

What I tried to do, is to pass a string value that is not on the context,
like this:

{% my_tag with param_str="a string here" %}

and

@register.inclusion_tag('my_tag.html',takes_context=True)
def my_tag(context):

    param_str = context['param_str']
    ...

But this give me the error:
TemplateSyntaxError at /my/url/

my_tag takes 0 arguments


Am I using the 'with' tag wrongly?

thanks,
Rodrigo Gomes

On Fri, Jun 17, 2011 at 5:31 AM, Tom Evans <tevans...@googlemail.com> wrote:

> On Thu, Jun 16, 2011 at 7:03 PM, Rodrigo Gomes <rgo...@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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to