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

Daniel Dekany commented on FREEMARKER-33:
-----------------------------------------

The behavior of `MapModel` can't be changed because of backward compatibility. 
That's why instead {{simpleMapWrapper}} has to be set to {{true}}, and that's 
why it defaults to {{false}}. (Note however that `DefaultObjectWrapper` doesn't 
have this problem.) With {{SimpleMapModel}} {{#list ... as k, v}} (and 
{{?keys}} as far as the keys as {{String}}-s) works as expected, so accessing 
{{entrySet()}} is not needed (and if you still need to access the Java API of 
the object, you should use `?api`). Using `entrySet()` is the workaround if you 
are stuck with `MapModel`.

> <#list map as k,v> doesn't works as expected
> --------------------------------------------
>
>                 Key: FREEMARKER-33
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-33
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.25-incubating
>            Reporter: zhouyanming
>             Fix For: 2.3.26-incubating
>
>
> {code:java}
> package test;
> import java.util.HashMap;
> import java.util.Map;
> public class MapFactory {
>       public static Map<String, String> create() {
>               Map<String, String> map = new HashMap<>();
>               map.put("mykey", "myvalue");
>               return map;
>       }
> }
> {code}
> {code:html}
> <#list statics['test.MapFactory'].create() as k,v>
> ${k}
> </#list>
> {code}
> I am expecting "mykey" only, but it render others like "getClass values .." 
> also.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to