[MAGNOLIA-3829] Expose EL functions as shared variables. Created: 09/Sep/11 Updated: 04/Nov/15 Resolved: 04/Nov/15 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | freemarker |
| Affects Version/s: | 4.4.4 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Danilo Ghirardelli | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Patch included: |
Yes
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
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. sharedVariables
\- cmsfn
|- class info.magnolia.freemarker.StaticMethodsModel
\- targetClass info.magnolia.cms.taglibs.CmsFunctions
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. |
| Comments |
| Comment by Danilo Ghirardelli [ 09/Sep/11 ] |
|
STKUtil seems a good candidate to be exposed with this. |
| Comment by Michael Mühlebach [ 04/Nov/15 ] |
|
Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes. |