You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Tim Colson (Jira)" <ji...@apache.org> on 2021/02/12 19:13:00 UTC

[jira] [Commented] (VELOCITY-921) Add syntactic sugar for maps handling in #foreach

    [ https://issues.apache.org/jira/browse/VELOCITY-921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17283930#comment-17283930 ] 

Tim Colson commented on VELOCITY-921:
-------------------------------------

Seems like a reasonable proposal from back in Nov 2019.

I suspect it was discussed on the dev-list. I'm curious, Mr. [~cbrisson], what was the consensus opinion and action to take?

> Add syntactic sugar for maps handling in #foreach
> -------------------------------------------------
>
>                 Key: VELOCITY-921
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-921
>             Project: Velocity
>          Issue Type: New Feature
>          Components: Engine
>    Affects Versions: 2.2
>            Reporter: Claude Brisson
>            Assignee: Claude Brisson
>            Priority: Major
>
> `#foreach($x in $map)  defaults to iterating on map values. But what if we have to iterate on keys or on entries? Resorting to write #foreach($k in $map.keySet()) or #foreach($e in $map.entrySet()) always bothered me. Most of the time with maps, we'll want to iterate over keys or entries.
> The proposal is to introduce optional postfixed modifiers in the #foreach syntax, as follow:
> #foreach($k in $map entries)
> #foreach($k in $map keys)
> #foreach($k in $map values)
> the default being kept on values, as it is today. Applying the modifiers on anything else than a map would give an error.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org