Am So., 11. Nov. 2018 um 09:25 Uhr schrieb Daniel Dekany <[email protected] >:
> Saturday, November 10, 2018, 3:08:14 PM, Denis Bredelet wrote: > > > Hi, > > > > Le 9 novembre 2018 à 22:36, Christoph Rüger <[email protected]> a > écrit : > > > > Am Fr., 9. Nov. 2018 um 22:55 Uhr schrieb Daniel Dekany < > [email protected] > > : > > > > It's certainly tricky, but as far as I see possible (but then, who > > > > knows what will one find when actually working on it). It's also a > > feature missing a lot. It's especially missing for #list (I know that > > you need it for something else), because if you filter the items > > inside #list with #if-s, then #sep, ?hasNext, etc. will not be usable. > > > > Let me say that I disagree here. > > > > I do not think that closures are required for FreeMarker, nor that they > are a good idea. > > > > If we add new features to the FreeMarker *tempate engine* I would > > rather we focus on multi-part macro body rather than an advanced > language feature like closures. > > > > You can add ?filter and ?map if you want, a simple expression as > parameter should be enough. > > Yes, as I said, we certainly start with only allowing lambdas in > ?filter/?map, also certainly in ?contains. > Would be enough in my opinion and very useful. Is it possiblefor you to give some pointers to the code on how this could be implemented? I would maybe like to wrap my head around this a little bit. I started looking at seq_containsBI ( https://github.com/apache/freemarker/blob/a03a1473b65d9819674b285a0538fed824f37478/src/main/java/freemarker/core/BuiltInsForSequences.java#L291) and and reverseBI ( https://github.com/apache/freemarker/blob/a03a1473b65d9819674b285a0538fed824f37478/src/main/java/freemarker/core/BuiltInsForSequences.java#L264) just to find something related (seq_containsBI checks something) and reverseBI returns a new sequence. What I haven't found is a function which takes an Expression as a parameter. Is there something similar already or would that be a new thing? > > Multi-part macro body is also planned. Means, I know it definitely > should be added, but who knows when that's done... I mean, it's like > that for what, a decade? (: It's not even decided what it exactly > does, as there are many ways of approaching this. (I have my own idea > about what the right compromise would be, but others has other > ideas...) > > Filtering lists bothers me because the template language should be > (and somewhat indeed is) specialized on listing things on fancy ways > that used to come up when generating document-like output. (If it > doesn't do things like that, you might as well use a general purpose > language.) Thus, that filter is unsolved (filtering with #if is > verbose and spoils #sep etc.) bothers me a lot. > > BTW, ?filter and ?map is also especially handy in our case as > FreeMarker doesn't support building new sequences (sequences are > immutable). Although it has sequence concatenation with `+`, it's not > good for building a sequence one by one, unless the sequence will be > quite short. > Good point. > > > Cheers, > > -- Denis. > > -- > Thanks, > Daniel Dekany > > -- Synesty GmbH Moritz-von-Rohr-Str. 1a 07745 Jena Tel.: +49 3641 5596493Fax.: +49 3641 5596499 Internet: https://synesty.com <https://synesty.com> Geschäftsführer: Christoph Rüger Unternehmenssitz: Jena Handelsregister B beim Amtsgericht: Jena Handelsregister-Nummer: HRB 508766 Ust-IdNr.: DE287564982
