I am using this statement inside a Static Text webpart. it works if I don't include the outer IF. It doesn't render anything if I include it. Please help with syntax. thank you
{% if(Section2Header.lenth>0){ %} {% if(Section1HeadingType == 1){ %} <div class="row purple-bg"> <div class="col-md-1"> </div> <div class="col-md-10 mx-auto" style="max-width: 1200px;"> <p class="white-text my-2 {% Section1HeadingAlignment %}" ><strong>{% Section1Header %}</strong></p> </div> <div class="col-md-1"> </div> </div> {% } else { %} <div class="col-md-12 mx-auto" style="max-width: 1200px;"> <h1 class="h5 {% Section1HeadingAlignment %}" >{% Section1Header #%}</h1> </div>
{% }#%} {% }#%}
I would rather recommend considering writing a custom macro which will have the logic written in C# and then just output desired HTML. It might be cleaner solution and also better for performance. I would also try not to use the open condition and use it just like nested loops and conditions: {%if (condition A) {if (condition B) {...}} else {...}%}
{%if (condition A) {if (condition B) {...}} else {...}%}
Thank you. Custom macros are a little out of my realm at the moment. But I am very interested in learning how to write and use them.
Please, sign in to be able to submit a new answer.