blob: 9f5e5c4e9f13744871890e07d0e88b855675ec9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* global Mustache */
( function ( mw, $ ) {
// Register mustache compiler
mw.template.registerCompiler( 'mustache', {
compile: function ( src ) {
return {
/**
* @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 ) ) );
}
};
}
} );
}( mediaWiki, jQuery ) );
|