freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (FREEMARKER-8) Adding to a hash (map)
Date Tue, 10 Nov 2015 00:37:10 GMT

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

Daniel Dekany edited comment on FREEMARKER-8 at 11/10/15 12:36 AM:
-------------------------------------------------------------------

That's known but though one. FreeMarker doesn't access {{Map}}-s directly, instead it uses
{{TemplateModel}} interfaces like {{TemplateHashModelEx}}. That interface has no methods for
modifications. Of course we could add something like {{WritableTemplateHashModelEx}} which
extends {{TemplateHashModelEx}}, and then also had to update some of the built-in functions
which assume that these models are immutable. But before doing anything like that, there's
another higher priority issues, adding a model interface that allows non-string keys (would
be certainly called {{TemplateMapModel}}), and then extend that inferface to have writable
variation.


was (Author: ddekany):
That's known but though one. FreeMarker doesn't access {{Map}}-s directly, instead it uses
{{TemplateModel}} interfaces like {{TemplateHashModelEx}}. Those has no methods for modifications.
Of course we could add something like {{WritableTemplateHashModelEx}} which extends {{TemplateHashModelEx}},
and then also had to update some of the built-in functions which assume that these models
are immutable. But before doing anything like that, there's another higher priority issues,
adding a model interface that allows non-string keys (would be certainly called {{TemplateMapModel}}),
and then extend that inferface to have writable variation.

> Adding to a hash (map)
> ----------------------
>
>                 Key: FREEMARKER-8
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-8
>             Project: Apache Freemarker
>          Issue Type: New Feature
>          Components: engine
>    Affects Versions: 2.3.23
>            Reporter: Ondra Žižka
>
> It would be nice to assign to a map this way:
> {code}
> <#assign map["key"] = 1>
> {code}
> and also 
> {code}
> <#assign map["key"]++>
> {code}
> So far I think it's like this but can't get it work:
> {code}
> <#assign map += {classification.classification : map[classification.classification]!++}>
> {code}
> Thanks for considering.



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

Mime
View raw message