Reputation: 1835
I need to know the HTML to pass the CONTENT of a variable into a DJANGO CUSTOM TAG
the code, for example, would be something like this:
{% for id,name in data %}
{% customTag id name %}
{% endfor %}
I need this to pass the ACTUAL CONTENTS of id, and not just "id" (the literal string)
and the answer is NOT found at https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#passing-template-variables-to-the-tag like all the previous posts say
Upvotes: 1
Views: 2000
Reputation: 1835
Well somebody posted this and then removed it... but it answered my question. The answer was to use the takes_context
parameter.
I used a simple tag with this flag like in the example here https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#simple-tags
@register.simple_tag(takes_context=True)
def current_time(context, format_string):
timezone = context['timezone']
return your_get_current_time_method(timezone, format_string)
Upvotes: 1