You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (Jira)" <ji...@apache.org> on 2019/11/11 13:47:00 UTC
[jira] [Created] (VELOCITY-921) Add syntactic sugar for maps
handling in #foreach
Claude Brisson created VELOCITY-921:
---------------------------------------
Summary: 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
`#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