Tell me how twig can be configured so that there are no spaces and an empty string in the tags. Use {% - - %} is necessary for each line, and spaceless removes spaces only between tags, and in the tags themselves, if there is a tab in the code, the following occurs:

 <p>" text"</p> 

Is it possible to customize twig so that there are no spaces?

PS The project is written in symfony2.

  • No, just work with each tag. "It was not" written separately. - etki 1:56 pm
  • then how can you get rid of gaps in twig? - Kostiantyn Okhotnyk
  • Write your filter - tutankhamun
  • Only work with each tag. But this is HTML, you are doing something wrong if it is messed up inside block elements. Well, you can even generally filter all output and minify. - etki pm
  • Is minimizing output a server task, or can you minimize using symfony2? - Kostiantyn Okhotnyk

1 answer 1

{{var}} - "some"

{{var | trim}} - "some"

Read more - TWIG documentation: http://twig.sensiolabs.org/doc/filters/trim.html

  • Try to write more detailed answers. Explain what is the basis of your statement? - Nicolas Chabanovsky
  • @Nicolas Chabanovsky. Yes with pleasure. This is from the documentation: twig.sensiolabs.org/doc/filters/trim.html . There is a detailed example. - Jan Swiatecki
  • Thank! At Stack Overflow, the community expects to see detailed responses containing a specific example of the minimum solution, supplemented by a link to the source. We believe that the link responses (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky