I have just added a Screen and Layout to allow the use of FreeMarker
templates within Turbine.  The screen is completely commented out, so that
everyone not using FreeMarker will not receive a bunch of compile errors.  I
have implemented it very simply.  All the attributes of RunData are
available as well as ACL (permssions) as properties/variables to the
template along with a default URI:
http://host/servlets/Turbine/screen/FreeMarkerScreen.  These values are
accessible to the template as e.g.:

data.screen
data.title

acl.roles.admin (which will be true, if the User has role admin.)
acl.permissions.canAddUsers (which will be true, if the User has permission
"canAddUsers".)

links.default (which is
http://host/servlets/Turbine/screen/FreeMarkerScreen.)

It is my hope that a statement like <if data.permissions.canAddUsers> will
evaluate to false if the permission is not valid, but I did not check it
out.  It is possible to add methods, so that <if
data.permissions.hasPermission("canAddUsers")> is a possibility, but I have
not had time to implement it like this (someone else feel free.)

For displaying database queries etc, you should extend FreeMarkerScreen and
override the method freeMarkerBuild(data, modelRoot). And add additional
Models to modelRoot.

A very simple example can be found in the turbine/examples directory.  Set
the path property in TurbineResources and after logging in to Turbine enter
the url
<http://host/servlets/Turbine/screen/FreeMarkerScreen/freemarker/default.htm
l>

FreeMarker is an open source project.  The template library is covered under
LGPL.  It can be found at
<http://freemarker.sourceforge.net/>

Have fun and please help improve this interface.
John McNally



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to