phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
63 stars 3 forks source link

Scoping of for/each loop #41

Closed kylekatarnls closed 5 years ago

kylekatarnls commented 5 years ago

Issue with the following code:

- val = 42
p=val
ul
  each val in [1, 2, 3]
    li= val
p=val

Expected:

<p>42</p>
<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>
<p>42</p>

Current output:

<p>42</p>
<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>
<p>3</p>
kylekatarnls commented 5 years ago

Fixed in https://github.com/phug-php/compiler/releases/tag/0.5.26

Old behavior can be restored using the option 'scope_each_variables' => false

kylekatarnls commented 5 years ago

Now documented: https://phug-lang.com/#scope-each-variables-boolean-string