Odd behavior with nested loops

1 view
Skip to first unread message

ussmoss

unread,
Aug 15, 2009, 9:03:58 PM8/15/09
to PURE - JavaScript Templates Engine
I am getting a weird issues with the args.item field not being set
correctly when using a function in the directive. I have narrowed down
the issue to what in the directive causes it though I am not sure why.

Please refer to the following link for the complete source code:
http://friendpaste.com/3tgqGZVg2DU9UN0vkqbcLI

It seems this part of the directive:
'div.header div.type' : { 'type <- team.types' : { '.' : '#
{type.name}' } }

Breaks the item that is passed in this part:
'div.detailcontainer div.teamdetail img.image@src' : function(args) {
if(args.item['default_image'] != '') {
return args.item['id'] + '.png';
}
else {
return 'blank.png';
}
}

If that first part is commented out of the directive the image gets
the correct name otherwise undefined is returned. I used firebug to
dump the args variable in the function call. From what I saw it seems
it using the values from the first loop instead of resetting item.

Thank you in advance for you help and please let me know if I am
making a stupid mistake.

Mic Cvilic

unread,
Aug 17, 2009, 6:13:30 AM8/17/09
to Pure-Unobtrusive...@googlegroups.com
I tried some workarounds yesterday, but this needs some more investigations.
I've set an issue here: http://github.com/pure/pure/issues#issue/6 where
you can follow the progress.

Thanks for reporting.
Mic
> >
>

ussmoss

unread,
Aug 19, 2009, 11:13:55 PM8/19/09
to PURE - JavaScript Templates Engine
I wanted to check in and see if you knew when a possible fix might be
put in for this bug? Are there any work arounds that I can do in the
mean time?

Mic Cvilic

unread,
Aug 20, 2009, 2:11:22 AM8/20/09
to Pure-Unobtrusive...@googlegroups.com
To get the reference of a running loop item, you need to name it.
In your example that should be "team.item" or "type.item"
This was the initial idea of using nested loops in pure2.

Now, I need to look at why "item" is not the innermost loop.
I'm quite busy these days, and won't have the time to look at it right now.

Cheers,
Mic

ussmoss

unread,
Aug 20, 2009, 2:23:41 AM8/20/09
to PURE - JavaScript Templates Engine
Super thanks for the quick reply. That worked like a charm. Thanks
again for making such a great template library :-)
Reply all
Reply to author
Forward
0 new messages