Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/75082


Change subject: add render function to Template class
......................................................................

add render function to Template class

- have wfTemplate use render() from the template class

ultimately, for improved testing, would be nice to get away from
using wfTemplate entirely! this allows instantiating a template
and render it in the same way as wfTemplate.

Change-Id: Ie246ae35e70dbdee5147aa1ee1b9d7254690dcce
---
M lib/WikibaseLib.php
M lib/includes/TemplateRegistry.php
2 files changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/82/75082/1

diff --git a/lib/WikibaseLib.php b/lib/WikibaseLib.php
index 486e4c5..761e8a3 100644
--- a/lib/WikibaseLib.php
+++ b/lib/WikibaseLib.php
@@ -190,8 +190,7 @@
 
                $template = new \Wikibase\Template( 
\Wikibase\TemplateRegistry::singleton(), $key, $params );
 
-               // Use plain() to prevent replacing {{...}}:
-               return $template->plain();
+               return $template->render();
        }
 
        // Resource Loader Modules:
diff --git a/lib/includes/TemplateRegistry.php 
b/lib/includes/TemplateRegistry.php
index ce423d3..79d7f75 100644
--- a/lib/includes/TemplateRegistry.php
+++ b/lib/includes/TemplateRegistry.php
@@ -50,7 +50,7 @@
         * @param array $templates
         */
        public function addTemplates( $templates ) {
-               foreach ( $templates AS $key => $snippet ) {
+               foreach ( $templates as $key => $snippet ) {
                        $this->addTemplate( $key, $snippet );
                }
        }
@@ -93,7 +93,8 @@
         * Constructor.
         *
         * @param TemplateRegistry $templateRegistry
-        * @param $key: message key, or array of message keys to try and use 
the first non-empty message for
+        * @param $key: message key, or array of message keys to try
+        *          and use the first non-empty message for
         * @param $params Array message parameters
         */
        public function __construct( TemplateRegistry $templateRegistry, $key, 
$params = array() ) {
@@ -107,11 +108,19 @@
         *
         * @return string template
         */
-       function fetchMessage() {
+       protected function fetchMessage() {
                if ( !isset( $this->message ) ) {
                        $this->message = $this->templateRegistry->getTemplate( 
$this->key );
                }
                return $this->message;
        }
 
+       /**
+        * @return string
+        */
+       public function render() {
+               // Use plain() to prevent replacing {{...}}:
+               return $this->plain();
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie246ae35e70dbdee5147aa1ee1b9d7254690dcce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to