jenkins-bot has submitted this change and it was merged.

Change subject: Register Hogan with mw.template
......................................................................


Register Hogan with mw.template

Use the mw.template version one for template compiling in
View.js

* Deprecate mw.mantle.template
* Fix documentation warnings

Change-Id: Ia7b74d229dd419a5cf2e5d20054e0067d76b366a
---
M includes/ResourceLoaderTemplateModule.php
M includes/Resources.php
M javascripts/common/View.js
M javascripts/common/templates.js
M javascripts/common/templates/hogan.js
5 files changed, 31 insertions(+), 16 deletions(-)

Approvals:
  Phuedx: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/ResourceLoaderTemplateModule.php 
b/includes/ResourceLoaderTemplateModule.php
index d88e9d7..d0f1b74 100644
--- a/includes/ResourceLoaderTemplateModule.php
+++ b/includes/ResourceLoaderTemplateModule.php
@@ -97,8 +97,11 @@
         * @return string JavaScript code for $context
         */
        public function getScript( ResourceLoaderContext $context ) {
+               $deprecationWarning .= Xml::encodeJsCall( 'mw.log.warn',
+                       array( 'ResourceLoaderTemplateModule is deprecated 
please use ResourceLoaderFileModule' )
+               );
                $script = parent::getScript( $context );
-               return $this->getTemplateScript() . $script;
+               return $deprecationWarning . $this->getTemplateScript() . 
$script;
        }
 
        /**
diff --git a/includes/Resources.php b/includes/Resources.php
index 6586312..1e59e3d 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -48,6 +48,7 @@
        ),
        'ext.mantle.hogan' => $wgMantleResourceBoilerplate + array(
                'dependencies' => array(
+                       'mediawiki.template',
                        'ext.mantle.templates',
                ),
                'scripts' => array(
diff --git a/javascripts/common/View.js b/javascripts/common/View.js
index 4534a89..1fcec8d 100644
--- a/javascripts/common/View.js
+++ b/javascripts/common/View.js
@@ -13,10 +13,10 @@
         * template property, this.$el will be filled with rendered template 
(with
         * options parameter used as template data).
         *
-        * template property can be a string which will be passed to 
M.template.compile()
+        * template property can be a string which will be passed to 
mw.template.compile()
         * or an object that has a render() function which accepts an object 
with
         * template data as its argument (similarly to an object created by
-        * M.template.compile()).
+        * mw.template.compile()).
         *
         * You can also define a defaults property which should be an object
         * containing default values for the template (if they're not present in
@@ -39,7 +39,7 @@
         *     var View, Section, section;
         *     View = M.require( 'View' );
         *     Section = View.extend( {
-        *       template: M.template.compile( "<h2>{{title}}</h2>" 
),
+        *       template: mw.template.compile( 
"<h2>{{title}}</h2>" ),
         *     } );
         *     section = new Section( { title: 'Test', text: 'Test section 
body' } );
         *     section.appendTo( 'body' );
@@ -104,7 +104,7 @@
                        // per object basis, but don't worry about it now 
(maybe add cache to
                        // M.template.compile())
                        if ( typeof this.template === 'string' ) {
-                               this.template = M.template.compile( 
this.template );
+                               this.template = mw.template.compile( 
this.template );
                        }
 
                        this.options = options;
diff --git a/javascripts/common/templates.js b/javascripts/common/templates.js
index 0648663..dfe2954 100644
--- a/javascripts/common/templates.js
+++ b/javascripts/common/templates.js
@@ -1,6 +1,8 @@
 /**
+ * A wrapper for templates. No longer supported use mw.template instead.
  * @singleton
  * @class mw.mantle.template
+ * @deprecated
  */
 ( function( $ ) {
 var
@@ -12,7 +14,7 @@
                 *
                 * @method
                 * @param {String} name the name of the compiler
-                * @param {HoganTemplateCompiler|HandlebarsTemplateCompiler} a 
compiler to associate with the name. Must implement a compile and 
registerPartial function.
+                * @param {Object} a compiler to associate with the name. Must 
implement a compile and registerPartial function.
                 */
                registerCompiler: function( name, obj ) {
                        if ( obj.compile ) {
@@ -50,8 +52,7 @@
                 *
                 * @method
                 * @param {String} name Name of template to be retrieved
-                * @return {Hogan.Template}
-                * accepts template data object as its argument.
+                * @return {Object} Compiled template
                 */
                get: function( name ) {
                        if ( !templates[ name ] ) {
@@ -64,7 +65,7 @@
                 * @method
                 * @param {string} templateBody Template body.
                 * @param {string} compilerName The name of a registered 
compiler
-                * @return {mixed} template interface
+                * @return {Object} template interface
                 * accepts template data object as its argument.
                 */
                compile: function( templateBody, compilerName ) {
@@ -80,4 +81,11 @@
                template: template
        } );
 
+       // Some deprecation notices
+       mw.log.deprecate( mw.mantle.template, 'compile', 
mw.mantle.template.compile,
+               'mw.mantle.template.compile is deprecated use 
mw.template.compile instead.' );
+
+       mw.log.deprecate( mw.mantle.template, 'get', mw.mantle.template.get,
+               'mw.mantle.template.get is deprecated use mw.template.get 
instead.' );
+
 }( jQuery ) );
diff --git a/javascripts/common/templates/hogan.js 
b/javascripts/common/templates/hogan.js
index 30adb28..5751df5 100644
--- a/javascripts/common/templates/hogan.js
+++ b/javascripts/common/templates/hogan.js
@@ -1,11 +1,10 @@
 // Register the Hogan compiler with MediaWiki.
 ( function( M ) {
-       /**
-        * @class HoganTemplateCompiler
-        * @singleton
+       /*
+        * Hogan template compiler
         */
-       M.template.registerCompiler( 'hogan', {
-               /**
+       var hogan = {
+               /*
                 * Registers a partial internally in the compiler.
                 * Not used in Hogan compiler
                 *
@@ -14,7 +13,7 @@
                 * @param {HandleBars.Template} partial
                 */
                registerPartial: function( /* name, partial */ ) {},
-               /**
+               /*
                 * Compiler source code into a template object
                 *
                 * @method
@@ -24,5 +23,9 @@
                compile: function( src ) {
                        return Hogan.compile( src );
                }
-       } );
+       };
+       // register hogan compiler with core
+       mw.template.registerCompiler( 'hogan', hogan );
+       // @deprecate
+       M.template.registerCompiler( 'hogan', hogan );
 }( mw.mantle ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/169931
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia7b74d229dd419a5cf2e5d20054e0067d76b366a
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to