X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.template.mustache.js;h=9f5e5c4e9f13744871890e07d0e88b855675ec9d;hb=f2327b448c13a5c40d6026eb9b1f6d2b6a7ff138;hp=dcc3842bc18a02d4bf5f2144f520487d0683919e;hpb=ba68d15a7594b4e9b4fa5235d81210843cbabca3;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.template.mustache.js b/resources/src/mediawiki/mediawiki.template.mustache.js index dcc3842bc1..9f5e5c4e9f 100644 --- a/resources/src/mediawiki/mediawiki.template.mustache.js +++ b/resources/src/mediawiki/mediawiki.template.mustache.js @@ -1,11 +1,31 @@ -/*global Mustache */ +/* global Mustache */ ( function ( mw, $ ) { // Register mustache compiler mw.template.registerCompiler( 'mustache', { compile: function ( src ) { return { - render: function ( data ) { - return $.parseHTML( Mustache.render( src, data ) ); + /** + * @ignore + * @return {string} The raw source code of the template + */ + getSource: function () { + return src; + }, + /** + * @ignore + * @param {Object} data Data to render + * @param {Object} partialTemplates Map partial names to Mustache template objects + * returned by mw.template.get() + * @return {jQuery} Rendered HTML + */ + render: function ( data, partialTemplates ) { + var partials = {}; + if ( partialTemplates ) { + $.each( partialTemplates, function ( name, template ) { + partials[ name ] = template.getSource(); + } ); + } + return $( $.parseHTML( Mustache.render( src, data, partials ) ) ); } }; }