FigDice is a template rendering system, primarily designed for web applications and the dynamic generation of HTML documents.
Inspired in 2005 by the work of the PHPTAL project, with the use of extended attributes which integrate seamlessly into HTML and make templates useable in WYSIWYG editors, the FigDice project is pioneering in its fundamental use of the inversion of control principle.
FigDice puts the view screens (templates) at the centre of the rendering process. Rather than be a passive receptacle for data prepared by the controller, they actively collect the information the web designer wants to present, directly invoking application services designed for this purpose.
The FigDice project is free software, licensed under GPL v3, started by Gabriel Zerbib.
FigDice is aimed at developers and Web designers working together as a team. The system, which respects the strict separation between presentation and logic, places Web design at the centre of the production of views, by giving greater importance to the design of near-functional Web templates by the designer.
If you are tired of writing templates which look nothing like HTML and which give too much space to pseudo-code, in applications which require that their controllers or logic layers have complete knowledge of every view to be produced, then FigDice is for you!
The fundamental principle of FigDice is to make the view itself responsible for calling the data it needs. This means FigDice places the view at the centre of the application and only the screens know the services invoked to produce them.
The controller no longer reassembles the data from the various services to inject them into a template - the template itself invokes the services, manipulates their data and decides which are to be presented and how.
On the application diagram, FigDice is located at the level of the view and presentation layers. The controller layer is generally where the FigDice View object must be constructed.
The elements (factories) necessary to make this object autonomous are passed to it so that, when rendered by the engine, it can obtain itself the data to be presented by the resulting page.
The FigDice concept applies the inversion of control principle in relation to data providers. The controller, via the objects factory, provides the view with access to the loading and on-demand instantiation to data supply services (feed), which encapsulate the access to the database and all other application resources (session, etc.).
Formalism and methodology
FigDice defines a simple notation based on XML tags and attributes, allowing the engine, using source files very close to the target HTML, to produce the rendering, dynamically enhanced by the Web application's services and presentation layers.
FigDice is independent of the programming language and the FigDice XML files are portable across its implementations.
The principle involves producing near-functional HTML templates, representing the screens as they should appear to the user, but containing arbitrary data in the place of the dynamic content to be added by the application (such as the items in a shopping basket). Using these templates, you transform the HTML into a valid XML document using a range of attributes and tags with the Â« fig: Â» namespace, whose role is to drive the rendering engine (conditions, loops, data, inclusions, etc.).
The data providers (feed) are invoked directly from the XML by instantiation of classes, to which access is provided by factories. These providers respond to the view of structured collections of data, which the view can use according to a formalism independent of the programming language and in complete safety.
Language and integration
FigDice is above all a concept, a notation and a methodology for constructing web applications.
The templates use a simple formalism specific to FigDice and are independent of any programming language.
A PHP implementation of the FigDice engine is currently available on this site.