Extension:Mantle

The Mantle extension promotes code sharing of code not quite ready for core.

Developer features
If your extension requires Mantle, check  in some early initialization function. (But not in MyExtension/MyExtension.php, as you cannot always get MyExtension to load after Mantle.)

Templates

 * See Requests for comment/HTML templating library for comparison of HTML templating libraries and future plans

Mantle can deliver HTML templates to front-end code using the ResourceLoader, and provides ResourceLoader modules with the JavaScript to compile and render Hogan and handlebars.js templates.

To use this, you define a module in  that lists your HTML templates, similar to other ResourceLoader modules. You must:
 * specify a  key listing the template names.
 * include either  or   in its   key
 * specify  where the named template files are.
 * specify  so these features work

Mantle's  class extends   so has all its features. In addition to supporting templates, it also extends supplying messages to JavaScript so that some message strings can be parsed in PHP. This is useful for elaborate message parsing that is not (yet) implemented in JavaScript. As of May 2014 it only supports.

Example:

in JavaScript
The general approach provided by Mantle's template code is
 * 1) A mention of someTemplate in a RL module generates a script tag with JavaScript that invokes.
 * 2) This immediately compiles the template (whether you want to or not, ).
 * 3) Call   to retrieve the template object.
 * 4) Call the object's   function, passing in a plain JavaScript object of template parameters.

Example: You can also  the code of a template, which isn't necessary if the template is mentioned in a ResourceLoader module.

Mantle does not yet support precompiling handlebars templates into JavaScript.

Other features

 * object-oriented JavaScript code, similar to OOjs: Class.js, eventemitter, View.js. As used by Extension:MobileFrontend.