You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Shawn Dempsay (JIRA)" <ji...@apache.org> on 2018/02/17 14:07:00 UTC
[jira] [Created] (FREEMARKER-89) Template rendering gets confused
with static functinos
Shawn Dempsay created FREEMARKER-89:
---------------------------------------
Summary: 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.27-incubating, 2.3.23
Reporter: Shawn Dempsay
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)