How do I DRY up common text in a Django template? -
I have some static text that should appear in 2 templates in the template.
For example:
& lt; Div & gt; {% If something%} is a static text {% else%} something happened {% endif%} & lt; / Div & gt; ... more HTML & lt; Span & gt; {% If something%} is a static text {% else%} some more laugh {% endif%} & lt; / Span & gt;
- I can duplicate the above text in 2 separate locations in my template file (as shown above).
- I also have a model that will store the text (it is tasty but the cost of call to DB for a normal work)
- I used the
included template
I'm thinking of using it, but maybe this is not the best way to achieve my goal.
What is the best way to do this?
{% if some%} is a static text {% Else%} something else happened {% endif%}
"Variations" can be passed as a variable on the template tag so that you use that entire block in the way of a variable Able to do
Comments
Post a Comment