Then i think that what you want is to create a custom template tag.
Read this entire section of the documentation. You probably want to create a inclusion_tag from what i understand.
I’m not sure I understand why you need to create a variable here in the template - aren’t you creating that variable in your view, and passing it to the rendering engine in the context?
As you can see I’ll be passing the formatting code as well for the detail_info since it is dynamic and I need to decide that while editing the template.
Personally, I wouldn’t organize it that way. (I’m still not sure I fully understand the situation - I’m sure these are simplified examples from what’s a more complex environment. And without having a clearer and more complete picture, I’m not sure that anything I could say here would satisfy all your core requirements.)
In the general case, I’d have my if tags in the included template, to determine which of the three “wrappers” around {{ data.info }} to use - but to handle that selection of formatting within the template.
What I might suggest is that you take a look at how Django itself uses templates for things like forms to see how they handle the various options available, and all the conditional template processing that occurs. It might give you some ideas for a different/cleaner approach.
Also be aware that you can include templates within an included template.