I am considering implementing a custom XWikiRenderer that uses FreeMarker (http://www.freemarker.org/) to render the xwiki templates (src\main\web\templates) and documents, as an alternative to velocity. I thought that it would be as simple as implementing a custom XWikiRenderer, however I discovered that * the XWikiVelocityRenderer exposes some static methods, which is used within a few different xwiki classes * VelocityContext instances are constructed and manipulated outside from the XWikiVelocityRenderer Are there any plans to refactor the code base to support custom XWikiRenderer implementations. My ideal goal would be to enable a mix of rendering engines - freemarker, velocity, or any other template language. However some metadata would be needed to inform the rendering api which template engine to use. To begin with - I'd like to be able to reuse all of the existing templates, but specify for a wiki, or for a space, that freemarker is the default rendering engine. Then an enhancement could be to allow each document to override this. Then - the next step could be to allow the templates to be written in freemarker. I am fairly experienced with freemarker having used it on a few web sites over the last few years. I also implemented the integration code for freemarker in webwork. Thanks, Cameron.
Hi Cameron, This looks like an interesting project. A few things that you need to be carefull about: As you have seen Velocity is used both for page rendering and template rendering. Changing the templates to use another engine is a lot of work. Also it is used from time to time for some specific rendering (tables for in displayForm, menus coming from the preferences, textarea field content using displayRendered). You can write your own rendered and add it to the rendering loop in the XWikiRenderingEngine constructor. We probably need to refactor the configuration of the rendering loop which could be in a config file. You could drop Velocity from the rendering loop but in this case the default wiki would probably not work any more, but you can start from an empty database. You need to be carefull with security. Velocity is great because it can only use objects that are in the velocity context but not use any Java. I don't know enough freemarker but you need to be carefull about this. You need to check how to handle the includes (the context needs to be shared one way or another). You need to be carefull about template language conflicts. The first renderers can have an effect on the content depending on the template language. So the order in which the template languages are called is important. Now some of these issues could be fixed. Indeed it would be great to configure a "default" template language and to override this in a document configuration. This would also improve the performance as we would not try to render things with all rendered. We would need to find something smart in this area. The default behaviour could be a template engine + wiki syntax. Usage of other templates engines or groovy could then be added manually to the page. There are also the plugins renderers (any plugin can be called in the rendering loop) which would need to be integrated somewhere. Anyway this looks interesting and we welcome you on board the XWiki contributors team ! Ludovic Cameron Braid a écrit :
I am considering implementing a custom XWikiRenderer that uses FreeMarker (http://www.freemarker.org/) to render the xwiki templates (src\main\web\templates) and documents, as an alternative to velocity.
I thought that it would be as simple as implementing a custom XWikiRenderer, however I discovered that
* the XWikiVelocityRenderer exposes some static methods, which is used within a few different xwiki classes
* VelocityContext instances are constructed and manipulated outside from the XWikiVelocityRenderer
Are there any plans to refactor the code base to support custom XWikiRenderer implementations.
My ideal goal would be to enable a mix of rendering engines - freemarker, velocity, or any other template language. However some metadata would be needed to inform the rendering api which template engine to use.
To begin with – I’d like to be able to reuse all of the existing templates, but specify for a wiki, or for a space, that freemarker is the default rendering engine. Then an enhancement could be to allow each document to override this.
Then – the next step could be to allow the templates to be written in freemarker.
I am fairly experienced with freemarker having used it on a few web sites over the last few years. I also implemented the integration code for freemarker in webwork.
Thanks,
Cameron.
-- Ludovic Dubost XPertNet: http://www.xpertnet.fr/ Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost AIM: nvludo Yahoo: ludovic
Yes definitely ! I think that is a great proposal to refactor and improve scripting / rendering engine support in XWiki in a modular manner and Freemarker seems to be quite an interesting and powerful approach, even though, as they say, there is a smaller community than Velocity. The differences with Velocity are explained here along with a list of features: http://www.freemarker.org/fmVsVel.html On 6/7/05, Ludovic Dubost <[email protected]> wrote:
Anyway this looks interesting and we welcome you on board the XWiki contributors team !
Ludovic
-- Luis Arias http://www.xwiki.com http://www.innover-entreprendre.net +33 6 14 20 87 93 mobile
participants (3)
-
Cameron Braid -
Ludovic Dubost -
Luis Arias