We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt is rendering HTML in a single line

Hi, I'm trying change this in my development enviroment but can't find where do it. I downloaded same samples and in this projects (INVO,Vokuro, Yona and others) all html output are normal with breaklines but in my self project the output are in a single line and to debug Javascript is very hard. Anyone know how change this, this is a volt or phalcon setting? Thanks for attention.



1.1k
Accepted
answer
edited Nov '17

Ops, i found the solution, my index.php in public folder had this line: echo str_replace(["\n","\r","\t"], '', $application->handle()->getContent());

sorry for inconvenient

Hi @mauro other simple way using {{- -}} and {%- -%}

{%- if categories is defined -%}
    {{- "<h1>Categories</h1>" -}}
    {{- "<ul>" -}}
    {%- for category in categories -%}
        <li>
        {{- '<span class="label label-default pull-right">' ~ category.number_posts ~ '</span>' ~ category.name -}}
        </li>
    {%- endfor -%}
    {{- "</ul>" -}}
{%- endif -%}

output

<h1>Categories</h1><ul><li>cat1</li><li>cat2></li></ul>

I hope it's help you. Good luck