freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ondra Žižka (JIRA) <>
Subject [jira] [Commented] (FREEMARKER-73) ?seq to convert some models to a sequence
Date Tue, 26 Sep 2017 07:33:00 GMT


Ondra Žižka commented on FREEMARKER-73:

Great! :) Recently, Freemarker has been becoming a lot more usable and universal, thanks to

Regarding hashes - I agree, let's not clutter the template language too much, and keep ?sequence
just for listable things.

And with Streams - I am still not accustomed to work with them, they feel like something volatile,
that should give the result and disappear. But while working with ReactiveX, I got used to
using this style, and eventually Streams could be a good addition to the models fed to the
view layers, e.g. Freemarker.

> ?seq to convert some models to a sequence
> -----------------------------------------
>                 Key: FREEMARKER-73
>                 URL:
>             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
> 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
> 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

View raw message