Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-73

?seq to convert some models to a sequence

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Implemented
    • 2.3.26-incubating
    • 2.3.27-incubating
    • engine
    • None

    Description

      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:

      <#assign foo = myIterable?seq>
      <#assign foo = myIterator?seq>
      • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            pekarna Ondra Žižka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: