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

How to disable phalcon from removing line breaks when rendering a view.

I have a .phtml view file which has JavaScript code. When Phalcon renders this view file, it removes line breaks which causes my JavaScript to break.

Probably you have some kind of output filter on Assets (minifier). But without actual code it is hard to tell which service is repsonsible for this trick.

edited Feb '19

Pardon my ignorance, how JS could become broken if you removed LF's? HTML does not "break" if you remove (CR)LF's, and neither does JS. And that's what minifiers do, they eat up all line feeds and blanks etc. But the code still works just fine in a browser as it does not care about LF's or CRLF's.



8.4k

in public/index.php change the following line:

echo str_replace(["\n","\r","\t"], '', $application->handle()->getContent()); to echo $application->handle()->getContent();