If you just want to keep the exact indent of the included subpattern, you can do this:
<header> <div id="menu"> {% include 'menu.twig' %} </div> </header>
i.e. put all the include directives at the beginning of the line. The result will be:
<header> <div id="menu"> <ul> <li>item 1</li> <li>item 2</li> </ul> </div> </header>
But somehow I feel that this is not enough. Another solution is to add padding to the sublayer, i.e.
<ul> <li>item 1</li> <li>item 2</li> </ul>
but, of course, it only works if the sub-tier is always included in a certain level of indentation.
I suggest you choose a completely different route and format the response after that it generates, for example. with kernel.response event listener.
source share