Extension:Mantle

The Mantle extension promotes code sharing of code between projects where there may be still disagreement on the approach but the code is used by teams, e.g. an outstanding RFC or the code is subject to change. Many MediaWiki extensions cut their own code to do the same thing – one good example is VisualEditor and MobileFrontend, the former which uses OOJS and the latter a lightweight Class-based approach. Mantle is a stopgap to help identify patterns between projects and promote standardization.

Currently the main purpose of this extension is to implement compilation into JavaScript of templates sent the server to the client by ResourceLoader, while the HTML templating language RFC is implemented.

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 provides a ResourceLoader module that can compile and render 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  in its   key
 * specify  where the named template files are.
 * specify

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.

Earlier Mantle features

 * general JavaScript template support: moved to ResourceLoader and to core's  module
 * object-oriented JavaScript code Class.js, eventemitter: deprecated in favor of OOjs
 * supplying parsed messages to JavaScript: moved back to Extension:MobileFrontend's
 * View.js: moved back into Extension:MobileFrontend.