Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional rendering of HTML segment using render_template

I am calling render_template from a couple of different places, and I'd like to control whether I render certain HTML segments, depending on where I'm calling from.

For example:

render_template('index.html', form=form, show_results=1)

I intended to use the show_results bool to flag whether the optional segment should be rendered or not. However, I'm missing what wrapper I should have in the optional delimited portion of the HTML code to control whether the segment should be rendered or not. How can I accomplish this?

like image 350
zanzu Avatar asked Jan 05 '15 20:01

zanzu


1 Answers

Use an if block:

{% if show_results %}
    show the results
{% endif %}
like image 120
davidism Avatar answered Sep 20 '22 19:09

davidism