The reason I was asking is that if all functionality goes in DataSourcers,
the methods will shadow data source names. Like if you have a data source
named "empty", then DataSources.empty will not return that, instead it will
call isEmpty(). That also means that adding new methods to DataSource is
not backward compatible. So probably we will need a separate DataSources,
and DataSourceTool or something. (It's also possible to reverse priorities,
but that's even less manageable for the user.)

Regarding toString() in  ${DataSources["github-users.json"].toString()}.
The model can just implement TemplateScalarModel if we need a default
string representation, and then it will be just
${DataSources["github-users.json"]}. (If you need to expose Java API, plus
call toString() for TemplateScalarModel, then you can use StringModel as
the super class.)


On Sat, Jul 4, 2020 at 10:27 PM Siegfried Goeschl <
[email protected]> wrote:

> Hi Daniel,
>
> Please see the examples in
> https://issues.apache.org/jira/browse/FREEMARKER-148 <
> https://issues.apache.org/jira/browse/FREEMARKER-148>
>
> Thanks in advance,
>
> Siegfried Goeschl
>
>
> > On 03.07.2020, at 23:25, Daniel Dekany <[email protected]> wrote:
> >
> > How do you intend to have map semantics and still expose helper methods?
> > I'm not asking how would you implement that, but how would it look in the
> > templates?
> >
> > On Tue, Jun 30, 2020 at 9:28 PM Siegfried Goeschl <
> > [email protected]> wrote:
> >
> >> Hi folks,
> >>
> >> Following up a discussion with Daniel I would like to make "DataSources"
> >> (contains the user-supplied data sources) a bit more FTL friendly
> >>
> >> Had a quick look at it but I'm a bit lost
> >> I created a DataSourcesAdapter which extends TemplateSequenceModel &
> >> TemplateHashModel
> >> DataSources has a few additional finder methods which I can't invoke
> when
> >> exposing the DataSourcesAdapter
> >> So the question is what interfaces needs to be implemented to support
> >> sequence semantics
> >> hash map semantics
> >> arbitrary helper methods
> >> in a single adapter
> >>
> >> Thanks in advance,
> >>
> >> Siegfried Goeschl
> >>
> >>
> >
> > --
> > Best regards,
> > Daniel Dekany
>
>

-- 
Best regards,
Daniel Dekany

Reply via email to