Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop bug #92

Closed
kargnas opened this issue Aug 4, 2013 · 8 comments
Closed

loop bug #92

kargnas opened this issue Aug 4, 2013 · 8 comments

Comments

@kargnas
Copy link
Contributor

@kargnas kargnas commented Aug 4, 2013

Code1

{loop="$array" as $myKey => $name}
    {$myKey|var_dump}
{/loop}

Result1

0
1

Code2

{loop="$array" as $name}
    {$key|var_dump}
{/loop}

Result2

0
1

Code3

{loop="$array" as $key => $name}
    {$key|var_dump}
{/loop}

Result3

NULL
NULL

Result3 should be same as other results.

@webnull

This comment has been minimized.

Copy link

@webnull webnull commented Aug 4, 2013

Yes it should be. Can you fix this bug?

@kargnas

This comment has been minimized.

Copy link
Contributor Author

@kargnas kargnas commented Aug 4, 2013

@webnull I did check parser code, but I can't fix this bug. So complex for me. (Maybe occur some side effects)

@webnull

This comment has been minimized.

Copy link

@webnull webnull commented Aug 4, 2013

I tried to implement string modifier and it was too complex for me too :)
But this bug is easy to bypass, so it can be fixed later i think.

@kargnas

This comment has been minimized.

Copy link
Contributor Author

@kargnas kargnas commented Aug 4, 2013

I think so.

@feulf

This comment has been minimized.

Copy link
Owner

@feulf feulf commented Aug 4, 2013

{$key}, {$value} and {$counter} are reserved variables, we cannot change this behavior because this works well for loop inside loop:

{loop="$array"}
     {$key} <--- this key is from the first loop
     {loop="$value.sub_array"}
          {$key} <--- this key is from the internal loop
     {/loop}
{/loop}

Rewriting the reserved variables could cause problems. Thanks for noticing this tho.

@webnull

This comment has been minimized.

Copy link

@webnull webnull commented Aug 5, 2013

@RainPHP maybe the reserved variables can be named $__key, $__value and $__counter?

@feulf

This comment has been minimized.

Copy link
Owner

@feulf feulf commented Aug 5, 2013

they are always been $key, $value and $counter, I want to maintain back compatibility and they're also easy to remember as they are now.

The documentation is clear about it:
http://www.raintpl.com/Documentation/Documentation-for-web-designers/RainTPL-Tags/_loop_%20array%20___loop_/

@feulf

This comment has been minimized.

Copy link
Owner

@feulf feulf commented Aug 25, 2013

I'm closing this

@feulf feulf closed this Aug 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.