Minus In twig block definition -


what's difference between this:

{%block body %} 

and that

{%block body -%} 

just read in documentation, not sure if apply on {% block ... %} tags. twig whitespace control

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

there's example given trims whitespace in front of variable doesnt't @ end - effect on 1 side.

{% set value = 'no spaces' %}     <li>    {{- value }}    </li> {# outputs '<li>no spaces    </li>' #} 

the above sample shows default whitespace control modifier, , how can use remove whitespace around tags. trimming space consume whitespace side of tag. it possible use whitespace trimming on 1 side of tag

so think difference in given exmaples in first block body there whitespace after block started. in second example body - there's none after block started. read documentation entry see how works.

edit

a simple example demonstrate example in docu:

{% set value = 'no space in source code after/before "value"' %} <li>    {{- value -}}    </li> ... 

outputs in firebug in html markup: no whitespaces afer value

whereas this

{% set value = 'space in source code after "value"' %} <li>    {{- value }}    </li> ... 

ouputs:

whitespace between "value" , closing </li>

notice space between "value" , closing </li> in second example. minus - erases/trims whitespace either before, after or on both sides of e.g. variable.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -