Hi,
I am trying to create a custom template tag that generates a repetitive HTML snippet. This tag is an anchor tag "a" with extra classes and styles, plus some logic to apply additional classes and styles. I want the syntax in the template to look something like:
{% my_anchor URL %}this is text between opening and closing tags{% end_my_anchor %}
Where URL is set to the href attribute of the anchor tag.
The rendered result should look something like:
<a class="myclass1 myclass2" style="mystyle1; mystyle2" href="URL">this is text between opening and closing tags</a>
I also do not want to hard code my URLs. So as one might expect, I am using the "url" template tag to create correct URLs. Naively, I tried to nest the tags:
{% my_anchor {% url ... %} %}this is text between opening and closing tags{% end_my_anchor %}
But this is invalid syntax. Is there a way to handle this?
Cheers
-- I am trying to create a custom template tag that generates a repetitive HTML snippet. This tag is an anchor tag "a" with extra classes and styles, plus some logic to apply additional classes and styles. I want the syntax in the template to look something like:
{% my_anchor URL %}this is text between opening and closing tags{% end_my_anchor %}
Where URL is set to the href attribute of the anchor tag.
The rendered result should look something like:
<a class="myclass1 myclass2" style="mystyle1; mystyle2" href="URL">this is text between opening and closing tags</a>
I also do not want to hard code my URLs. So as one might expect, I am using the "url" template tag to create correct URLs. Naively, I tried to nest the tags:
{% my_anchor {% url ... %} %}this is text between opening and closing tags{% end_my_anchor %}
But this is invalid syntax. Is there a way to handle this?
Cheers
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e3f4e619-0560-4f62-ad28-dd4775e2e3c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment