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

Daniel Dekany edited comment on FREEMARKER-73 at 9/30/17 11:25 AM:
-------------------------------------------------------------------

{{sometimesNull!?sequence}} would be {{[]}}. Why? Magic! (: Kind of... I never 
liked for `exp!` for it, but it's result is a multi-typed value that is empty 
string and empty sequence and empty hash. Hence {{?sequence}} just bypasses it.

Seems your data-model is not like those in typical business applications. Which 
is fine as FM and its friends were pretty much deprecated by AngularJS and 
Vaadin on that filed, so at least in FM3 there's a strong emphasis on stranger 
use-cases. Is this for Windup BTW?


was (Author: ddekany):
{{sometimesNull!?sequence}} would be {{[]}}. Why? Magic! (: Kind of... I never 
liked for `exp!` for it, but it's result is a multi-typed value that is empty 
string and empty sequence and empty hash. Hence {{?sequence}} just bypasses it.

Seems your data-model is not like hose in a typical business application. Which 
is fine as FM and its friends where pretty much deprecated by AnuglarJS and 
Vaadin on that filed. Is this for Windup BTW?

> ?seq to convert some models to a sequence
> -----------------------------------------
>
>                 Key: FREEMARKER-73
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-73
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.26-incubating
>            Reporter: Ondra Žižka
>             Fix For: 2.3.27-incubating
>
>
> The objects I feed to FreeMarker often cotain {{Iterator}}s rather than 
> {{Collection}}s.
> While it's quite easy to write a FreeMarker function 
> {{iteratorToList(Iterator)}}, it would be convenient to have the following:
> A built-in that would convert various models to a sequence. Could be named 
> {{?seq}} or {{?sequence}}.
> Usage:
> {code}<#assign foo = myIterable?seq>{code}
> {code}<#assign foo = myIterator?seq>{code}
> * A sequence would stay intact.
> * An {{Iterable}} wrapped in FM model would become internally a {{List}} - 
> all elements consumed and stored.
> For me, other cases are not that important, but with some imagination, other 
> models could also leverage it, like,
> * A {{Stream}} could be also turned into a {{List}}.
> * A hash could turn into a sequence of key/value pairs. That could be useful 
> for debugging purposes.
> I am not sure if I didn't propose that already, but I could only find 
> FREEMARKER-62.
> Thanks for considering.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to