X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.template.mustache.js;h=9f5e5c4e9f13744871890e07d0e88b855675ec9d;hb=a63770525dca7e271719d8f00ce0e2ced226c411;hp=624986a9bb8ada9b81a36999fcec3a35bba5b866;hpb=8c087b9fd13d9302ec1be2176ef1ae344b3f8273;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.template.mustache.js b/resources/src/mediawiki/mediawiki.template.mustache.js index 624986a9bb..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 ) ) ); } }; }