1👍
✅
I think that you should avoid the logic in the template.
I suggest 2 options :
- Prepare the name of the template in your view
- Or, create a template tags so you can deal with the logic outside the template.
Source:stackexchange.com