Pig
Pig

Reputation: 2122

Django: Can template tags prevent content to be rendered to the clients?

{% if foo == 1 %}

<-- blah blah blah -->>

{% endif %}

If the if block above evaluates the false, would the content inside the if block still be rendered to the client but hidden instead? If not, is this method an acceptable way to reduce page load?

Upvotes: 0

Views: 59

Answers (1)

Derek Kwok
Derek Kwok

Reputation: 13058

Yes, any content within the {% if condition %} and {% endif %} tags will not be sent the client if condition evaluates to False. It is not hidden via CSS, the content will simply not exist in the response.

It will also reduce the size of your HTTP response.

Upvotes: 1

Related Questions