pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

Automatically change the created object after the loop? #108

Closed dzpt closed 7 years ago

dzpt commented 7 years ago

Today i notice that the parsing engine automatically changes the created object after the loop. Example: i have the topic object with phone property div=$topic->phone

behind it i have the $topics list which contains many other $topic objects and show each of item like this:

each topic in topics
 // anything in the block

Then the $topic->phone at the beginning will be change to the $topic->phone (the item of $topics) I can't use the $topic after the loop

I can't use the same object name in the page?!

kylekatarnls commented 7 years ago

Indeed each is not scoped, it means you get the PHP native behaviour, like when you do:

$topic = 1;

foreach (array(2) as $topic) {
}

// now $topic = 2