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