cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker template date error

paulossilva
Champ in-the-making
Champ in-the-making
Hi,

Using the following code to get the current date in a freemarker template (as stated in the Alfresco template guide)

<#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">
${date?string(datetimeformat)}

gets me an error message like this:

error regenerating rendition using resolucoes_sgp.ftl: freemarker.template.TemplateException: Expected number, date, or string. date evaluated instead to freemarker.ext.dom.NodeListModel on line 6, column 3 in freemarker_template.

Any thoughts about that? I'm using the 2.1.0 Community version.
3 REPLIES 3

kevinr
Star Contributor
Star Contributor
We have identical working code in many templates - are you sure that is the line the template is failing on?

Kevin

kevinr
Star Contributor
Star Contributor
I think i've just spotted the problem Smiley Happy

I assume you are using FreeMarker for WCM rather than standard Alfresco templates. Unfortunately the WCM FreeMarker integration does not have the same model available for it - which is very annoying I'm sure you'll agree. Basically the "current date" is missing in FreeMarker by default (very odd isn't it!) so we had to add it -and i think it's missing from the model you get in WCM…

Thanks,

Kevin

kvc
Champ in-the-making
Champ in-the-making
You can track the status of this improvement request in our JIRA:

http://issues.alfresco.com/browse/WCM-1030

Cheers.

Kevin