Urs Hunkler has developed a Mustache theme for Moodle 2.9 which is based on the Mustache template and is a good effort to separate design-related things from logic-related things.
The basic features of the Mustache theme are:

Post Pages - Post Inline - WIRIS
  • The theme is based on autoloading renderer and renderable classes for the different page layouts. One renderer class, one »base_layout« renderable class with the common functionality and one renderable class for each layout which extends the »base_layout«.
  • There is only one central »layout.php« file.
  • The different page layouts are defined in the »$THEME->layouts« array. I added a new ‘renderable’ item holding the renderable class name that will be used.
  • There is one »wrapper« template with the header and footer part that is common for all page layouts.
  • With a dynamic partial Mustache helper the individual page partial template is included into the wrapper template. The name of the partial to use is set in the renderable for the layout type in a variable.
  • The dynamic partial helper renders the Mustache partial tag with the given partial template name.
  • I added the dynamic partial helper to the helpers in core. This helper I had developed for my former Moodle Mustache themes.
  • The information from the theme settings are added to the template variables directly in the renderable classes. I removed the function from »lip.php«.

Another valuable aspect of Mustache templates is that you can create representations of page areas in a template.

  • With PHP you can use this template on the server to render the HTML page delivered to the browser.
  • With Javascript you can use the exactly same template to render the page area in the browser when the data has been delivered for example from an AJAX call.

For full details, please check out this forum thread.
To learn more about the Mustache template check out the official page on Github.

Previous articleNext Moodle General Developer Meeting is 4/21/2015 @ 3am EST
Next articleLightbox Gallery updated for Moodle 2.8


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.