You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Steven Davelaar (Jira)" <ji...@apache.org> on 2021/02/24 14:50:00 UTC
[jira] [Created] (FREEMARKER-178) Using map or filter built-ins
looses custom template model
Steven Davelaar created FREEMARKER-178:
------------------------------------------
Summary: Using map or filter built-ins looses custom template model
Key: FREEMARKER-178
URL: https://issues.apache.org/jira/browse/FREEMARKER-178
Project: Apache Freemarker
Issue Type: Bug
Components: engine
Affects Versions: 2.3.30
Reporter: Steven Davelaar
When you are using a custom template sequence model that implements the
TemplateModelWithAPISupport interface so you can use the api built-in, you can no longer use the api built-in once you have applied the map or filter function, because the map and api functions then return a new instance of TemplateModelListSequence, which does not implement the TemplateModelWithAPISupport interface.
For example, imagine a custom sequence model that supports the toString() method, then the following works fine:
{noformat}
${myList?api.toString()}{noformat}
However, when I apply a filter, like this:
{noformat}
${myList?filter(i -> i.name == 'foo')?api.toString()}{noformat}
I get a APINotSupportedTemplateException because the filter has returned a TemplateModelListSequence instance.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)