How test is string is empty in jinja template for document


I createda custom template for quotation. Each item in the quotation can or cannot have a description.

If description is defined, it should be shown. If no description is defined, it should not display anything.

The problem is that if no description is defined, a blank line is displayed.

I tried a lot of things. The last attempt was:

		<td style="width: 48%;">
                            {{ row.item_name }}
                            {% if row.description != '' -%}
                                This is a test
                                [{{ row.description }}]
                            {%- endif %}

It did not work. How can I do it?

I am printing “This is a test” text only to check if the “if” statement works or not.

when seen page source, I see that “description” property has the value of


Is there a way to clean that HTML?


html2text function is accessible from Jinja templates in Frappe.

You can use it like so:

html2text("<div><br><div>").strip()  # outputs empty string

Edit: You can also try the striptags filter available in Jinja.