Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / resources / src / mediawiki / mediawiki.template.mustache.js
blob7f62256adf1b3cab437f095e0347c01fd8558d3e
1 /*global Mustache */
2 ( function ( mw, $ ) {
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                                  */
20                                 render: function ( data, partialTemplates ) {
21                                         var partials = {};
22                                         if ( partialTemplates ) {
23                                                 $.each( partialTemplates, function ( name, template ) {
24                                                         partials[ name ] = template.getSource();
25                                                 } );
26                                         }
27                                         return $( $.parseHTML( Mustache.render( src, data, partials ) ) );
28                                 }
29                         };
30                 }
31         } );
33 }( mediaWiki, jQuery ) );