General developer forum

Add mustache helper

 
Picture of Durif Anthony
Add mustache helper
 

Hello,

I try to develop a new local plugin. For some actions I have a list of links in my templates but I don't know how to display them.

The best would be to use the function moodle_url() in my templates, so I created a new mustache helper (to my mind there was aldready not a mustache helper for that in moodle core).

It's pretty simple and for now I added it in my own renderer (it extends core_renderer and add my helper in the get_mustache() function) and on my own theme and I used it like this:

{{#my_url}}/local/my_plugin/index.php{{/my_url}}   => displays https://mymoodle.com/local/my_plugin/index.php


My question is: is there a method to add (dynamically maybe) a custom mustache helper in the renderer without create our own renderer ?

For exemple if I want to share my plugin I need to also share the renderer, right ?


Thanks for your ideas and sorry for my rough english smile

Anthony.

 
Average of ratings: -
Picture of Michael Aherne
Re: Add mustache helper
Core developersParticularly helpful MoodlersPlugin developers

You can't - it seems to have been a deliberate design decision when introducing mustache: https://moodle.org/mod/forum/discuss.php?d=311120. There's a lot more discussion about it here too: https://moodle.org/mod/forum/discuss.php?d=311119#p1245495

 
Average of ratings: -