I need a unique identifier for every occurrence of a templatetag. Is it possible to get the actual filename, line number and column where the templatetag is used?
I thought about using a variable in the context to count the instances of my templatetag but this would result in numbers being assigned twice if i had the following situation:
{% mytemplatetag %}
{% if random %}
Some Text {% mytemplatetag %}
{% else %}
Some other Text
{% endif %}
{% mytemplatetag %}
If random is true the templatetags would get the numbers 1,2 and 3. If random is false only the first and last templatetag gets a number and therefore numbers get assigned differently.
I just need a unique id for all the instances of mytemplatetag in the above example.
In your template tag you got the parser. You can use it to get the source file and the current character in the template like this: