Expose EL functions as shared variables.
----------------------------------------
Key: MAGNOLIA-3829
URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-3829
Project: Magnolia
Issue Type: Improvement
Security Level: Public
Components: freemarker
Affects Versions: 4.4.4
Reporter: Danilo Ghirardelli
Attachments: StaticMethodsModel.java
In freemarker you can use jsp tag libraries, but you can't use directly EL
Functions. There is the possibility to put in the model all static methods,
accessing them with statics[full.package].method(), but this has two drawbacks:
you have to expose all of the static methods in your entire system, and you
have to put always the complete package and classname for each call.
The attached class is a wrapper for a class, exposing all of its static methods
in a map. To use this class, declare a node under
/server/rendering/freemarker/sharedVariable with the name you want to use as
placeholder, and two node data: "class" with the full package of this class,
and "targetClass", with the full package of the class with static methods you
want to expose.
For example:
{noformat}
sharedVariables
\- cmsfn
|- class info.magnolia.freemarker.StaticMethodsModel
\- targetClass info.magnolia.cms.taglibs.CmsFunctions
{noformat}
and then you can use ${cmsfn.canEdit()} in your template.
There were no examples on how to declare shared variables and what interfaces
should be extended, I thought this may be left as an example just in case.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------