Opened 6 years ago

Closed 6 years ago

#16897 closed enhancement (invalid)

dtl for-tag iterating over properties loses reference to key

Reported by: Stefan Meyer Owned by: Stefan Meyer
Priority: undecided Milestone: tbd
Component: DojoX DTL Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

I asked this on the mailing list and there was no answer. Therefore I post this here.

When iterating over properties of an object the for-tag creates an array from the values of the properties. Unfortunately the key cannot be accessed in the template:

consider an object:

var fruit={name:"apple",color:"red"}

consider a temlate:

{% for value,key in fruit %}

{{key}}:{{value}}

{% endfor%}

This will result in a string error because the value of key is undefined.

I fix it in logic.js by adding the keys as the second argument. My fix was not very good because it seems that the reference to the variable is lost in any nested tags like if and for.

Change History (2)

comment:1 Changed 6 years ago by ben hockey

Owner: changed from Neil Roberts to Stefan Meyer
Status: newpending

got a patch? for all intents and purposes, dtl is abandoned.

comment:2 Changed 6 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.