freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (FREEMARKER-89) Template rendering gets confused with static functinos
Date Sat, 17 Feb 2018 19:42:01 GMT

     [ https://issues.apache.org/jira/browse/FREEMARKER-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Daniel Dekany closed FREEMARKER-89.
-----------------------------------
    Resolution: Information Provided

OK, I have closed it then.

> Template rendering gets confused with static functinos
> ------------------------------------------------------
>
>                 Key: FREEMARKER-89
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-89
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>    Affects Versions: 2.3.23, 2.3.27-incubating
>            Reporter: Shawn Dempsay
>            Priority: Major
>
> I have an immutable class that shares naming for a field and a static getter:
> package org.dempsay.demo.freemaker.api;
>  
>  
> {code:java}
> public class Sample {
>     public final String data;
>     protected Sample(final SampleBuilder builder) {
>         this.data = builder.data;
>     }
>     public static String data(final Sample sample) {
>         return sample.data;
>     }
> }
> {code}
>  
> When I render it with the following template:
> {code:java}
> The data from this sample is ${sample.data}
> {code}
> I get this error:
> Feb 17, 2018 7:59:40 AM freemarker.log._JULLoggerFactory$JULLogger error
> SEVERE: Error executing FreeMarker template
> FreeMarker template error:
> For "${...}" content: Expected a string or something automatically convertible to string
(number, date or boolean), or "template output" , but this has evaluated to a method+sequence
(wrapper: f.e.b.SimpleMethodModel):
> ==> sample.data  [in template "sample.ftl" at line 1, column 32]
>  
> ----
> Tip: Maybe using obj.something(params) instead of obj.something will yield the desired
value
> ----
>  
> ----
> FTL stack trace ("~" means nesting-related):
> - Failed at: ${sample.data}  [in template "sample.ftl" at line 1, column 30]
> ----
>  
> The full code for this is posted in github at: https://github.com/sdempsay/freemarker-bug
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message