[
https://issues.apache.org/jira/browse/VELOCITY-921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claude Brisson closed VELOCITY-921.
-----------------------------------
Resolution: Won't Fix
It can have side effects, so better keep the explicit syntax.
> 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.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]