ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

{% } meaning in html


#1

hello ,
i just have a simple question to clarify a point
what does this mean
{% if (filters.party_name) { %}
{%= filters.party_name %}
{% } else if (filters.party) { %}
{%= filters.party %}
{% } else if (filters.account) { %}
{%= filters.account %}
{% } %}
when do i need to close %} and open them
because i have a code just to show CR or DR to a report but somehow it doesn’t enter the else if statement
and that’s my code
{% if (format_currency(data[i].balance > 0)) {%}
{%= __(“DR”) %}
{% } else if (format_currency(data[i].balance < 0)) { %}
{%= __(“CR”) %}
{% } %}

i might not understand the { % usage.
any help?


#2

conditional loop

{% %}

tempalte syntax


#3

thanks for your reply
it might be a dumb question but how can i integrate a for loop on this section with this syntax i know coding but this syntax seems weird to me
{% if (format_currency(data[i].balance > 0)) {%}
{%= __(“DR”) %}
{% } else if (format_currency(data[i].balance < 0)) { %}
{%= __(“CR”) %}
{% } %}
thanks in advance


#4

The syntax does take some getting used to. The Jinja 2 documentation will help but there are a lot of Frappe specific patterns you might need to glean. Every time I come back to this it takes some time to get back up to speed.
I think you might be missing an {% endif %} tag.
The {%= syntax indicates a variable to be rendered.
What’s also confusing is that the render_template JS function uses a similar-but-not-the-same template syntax.


#5

hello @tmatteson,
i’ll try to check the documentation but as far as i saw it,
it will help me a lot to understand it,
at least now i have a lead on where to start.
Thanks a lot for your help !