General developer forum

Moodle mod template with mustache

 
Picture of Christos Savva
Moodle mod template with mustache
Group Plugin developers

Hello is there any moodle mod starting point code template using mustache, like the one below?


https://github.com/moodlehq/moodle-mod_newmodule


If yes, could you please give me the link, if no are there any plans to create something?


Thanks in advance

Christos

 
Average of ratings: -
Picture of Hittesh Ahuja
Re: Moodle mod template with mustache
Group Plugin developersGroup Testers

Just search the Moodle code base for moustache braces .. you'll find loads.. for example https://github.com/moodle/moodle/blob/06e3b6d8bab42b8e56d169d006f31f4a15684830/theme/boost/templates/core_form/element-button.mustache

 
Average of ratings: -
Picture of Christos Savva
Re: Moodle mod template with mustache
Group Plugin developers

Thanks for the reply.


The problem I wanted to solve is: what is the best filestructure of a potential new moodle plugin using mustache.


When I checked the block_myoverview for example I can see that there is a folder called classes and a file called renderer.php which calls


return $this->render_from_template('block_myoverview/main', $main->export_for_template($this));


That's why I asked for a skeleton plugin using mustache. If there is no skeleton plugin, are there any guides on how to develop a plugin using mustache?

 
Average of ratings: -
Picture of Hittesh Ahuja
Re: Moodle mod template with mustache
Group Plugin developersGroup Testers

Ah I see. To be fair, I want to use mustache in a plugin soon but havent had the chance yet. Maybe look here for a start and work your way through https://docs.moodle.org/dev/Templates#How_do_templates_work_with_renderers.3F


I dont think there is a base plugin which shows how to implement mustache step by step 

 
Average of ratings: -
Picture of David Mudrák
Re: Moodle mod template with mustache
Group Core developersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Plugin developersGroup Plugins guardiansGroup TestersGroup Translators

are there any guides on how to develop a plugin using mustache?

I assume you are aware of https://docs.moodle.org/dev/Templates

Mustache templates should be seen as an additional layer on top of "legacy" Moodle rendering machinery. Or better, as an alternative to generating the HTML.

Your plugin should still implement its renderer. Just instead of having the HTML generated via calls like $this->output->heading() or html_writer::div() and friends, you actually delegate HTML generating to Mustache templates.

 
Average of ratings: -
Picture of Christos Savva
Re: Moodle mod template with mustache
Group Plugin developers

perfect thanks i will study those smile

 
Average of ratings: -