A Moodle renderer is a class that handles all the output for a component of Moodle and it should not contain any logic other than what is required to generate the display. This is the standard description of a Moodle renderer but how to make full use of the Moodle renderers and code the display logic for your plugin.
Introduced in Moodle 2.0, Moodle renderers are now expanded to make use of the templates, using the Mustache templating language. The use of templating language enabled the separation of HTML from PHP/JavaScript to allow the theme designers more creatively.
If you are also getting started with the Moodle theming and would like to learn about the renderers and templating then you can get started with this Moodle docs guide and this guide. However, if you would like to refer a practical hands on experience with overriding the renderers and templating mechanism in a plugin, then here is nice hands on tutorial for you.
The tutorial series written by Mike Churchward, Executive Director of POET group is good starting point for all Moodle theme designers who would like to get started with the Moodle renderers and templates. During the hands on experience tutorial, Mike refactored the “Questionnaire” plugin and improved the plugin output. The tutorial series covers the following topics:
- Part 1 – Setting up the Renderer
- Part 2 – Using the Renderer
- Part 3 – Setting up Templates
- Part 4 – Using the Template
- Part 5 – Further discussion
There is another video demo by Damyon Wiese showing the JavaScript, Ajax and templates in Moodle recorded during the MoodleMoot Australia 2015 Hackfest. Check it out below:
[ulp id='ntmi4JeMQ49mpBRm']