Format HTML in Scriban

1k views Asked by At

using scriban with SXA we notice the generated HTML has a lot of white spaces ex :

<div id=”dv1”>


           <div id=”dv2”>

This is because in scriban we have if condition before rendering the div with id=de2 , is there a way to format the html ?

1

There are 1 answers

0
NeilMacMullen On BEST ANSWER

It would be helpful if you posted the Scriban snippet you are using. I suspect you need to use ~ operator at the end of your if code block as described here

For example:

<div 1>


{{- #eat all whitespace to left including newlines
    if true
    #eat whitespace but not newlines to right  ~}}

    <div 2>
{{end}}
 

outputs

<div 1>
    <div 2>

You can use this tool to experiment with formatting.