arnaud-lb / MtHamlBundle

Symfony2 HAML bundle
38 stars 13 forks source link

Support for tag-level whitespace control #17

Open gentisaliu opened 9 years ago

gentisaliu commented 9 years ago

Twig 1.1 introduced tag-level whitespace control which works by adding a minus ("-") to the curly brackets as below:

 {% set value = 'no spaces' %}
 {#- No leading/trailing whitespace -#}
 {%- if true -%}
     {{- value -}}
 {%- endif -%}

{# output 'no spaces' #}

Also see the documentation.

Does MtHamlBundle/MtHaml support these at this time? I realize this should be challenging, considering the HAML syntax.

arnaud-lb commented 9 years ago

It does, but only partially and it's not particularly elegant:

-- if true -
   = value

The above compiles to:

{%- if true -%}
  {{ value }}
{% endif %}