Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / src / mediawiki.template.mustache.js
blobeda79c10531e985c35ad9ed03ccda3d3a6121a74
1 /* global Mustache */
2 ( function () {
3         // Register mustache compiler
4         mw.template.registerCompiler( 'mustache', {
5                 compile: function ( src ) {
6                         return {
7                                 /**
8                                  * @ignore
9                                  * @return {string} The raw source code of the template
10                                  */
11                                 getSource: function () {
12                                         return src;
13                                 },
14                                 /**
15                                  * @ignore
16                                  * @param {Object} data Data to render
17                                  * @param {Object} partialTemplates Map partial names to Mustache template objects
18                                  *  returned by mw.template.get()
19                                  * @return {jQuery} Rendered HTML
20                                  */
21                                 render: function ( data, partialTemplates ) {
22                                         const partials = {};
23                                         if ( partialTemplates ) {
24                                                 for ( const name in partialTemplates ) {
25                                                         const template = partialTemplates[ name ];
26                                                         partials[ name ] = template.getSource();
27                                                 }
28                                         }
29                                         return $( $.parseHTML( Mustache.render( src, data, partials ) ) );
30                                 }
31                         };
32                 }
33         } );
35 }() );