In my opinion, the problem with template tags are:
- Too much abstraction.
- Challenging to test.
- Problems with performance
What I suggest instead is:
- Create a function that generates the data, caches the data, handles permissions, anything else data related
- Write three more functions that render the data in HTML, JSON, and XML respectively
- Document and write tests for the above functions
- Use these functions in views, filters, and template tags as needed. The views/filters/tags calling the functions would be very thin and easy to manage.
The benefits you get by this approach are:
- Reusable code
- More easily testable code
- Better speed