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

Change subject: Add helper 'stringOrArray' for class values
......................................................................


Add helper 'stringOrArray' for class values

The personal_urls array items for Echo notifications can have an array for
'class', which causes PHP warnings from Skin.template's simplistic
   class="{{class}}"

Bug: T113566
Change-Id: I4b0178b7f01282e1a766ffce9159f0c68f1d190a
---
M src/BlueprintSkinTemplate.php
M templates/Skin.mustache
2 files changed, 11 insertions(+), 5 deletions(-)

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



diff --git a/src/BlueprintSkinTemplate.php b/src/BlueprintSkinTemplate.php
index 30a77f4..dcb667f 100644
--- a/src/BlueprintSkinTemplate.php
+++ b/src/BlueprintSkinTemplate.php
@@ -2,8 +2,6 @@
 
 class BlueprintSkinTemplate extends QuickTemplate {
        public function execute() {
-               global $wgBlueprintLeftNav;
-
                $this->data['debughtml'] = MWDebug::getDebugHTML( 
$this->getSkin()->getContext() );
                $this->data['left_nav_sections'] = $this->getLeftNav();
                $this->data['username'] = 
$this->data['personal_urls']['userpage'];
@@ -74,13 +72,21 @@
                $templating = new SimpleLightNCandy( __DIR__ . '/../templates' 
);
 
                $templating->addHelper( 'msg',
-                       function( array $args, array $named ) {
-                               $message = null;
+                       function( array $args /*, array $named */ ) {
                                $str = array_shift( $args );
 
                                return wfMessage( $str )->params( $args 
)->text();
                        }
                );
+               // Helper for CSS class values @see T113566.
+               $templating->addHelper( 'stringOrArray',
+                       function( array $args /*, array $named */ ) {
+                               if ( is_array( $args[0] ) ) {
+                                       return implode( ' ', $args[0] );
+                               }
+                               return $args[0];
+                       }
+               );
 
                return $templating->getTemplate( 'Skin' );
        }
diff --git a/templates/Skin.mustache b/templates/Skin.mustache
index 327d557..ca54046 100644
--- a/templates/Skin.mustache
+++ b/templates/Skin.mustache
@@ -28,7 +28,7 @@
                                                </a>
                                                <ul class="dropdown-menu" 
role="menu">
                                                        {{#each personal_urls}}
-                                                               <li><a 
href="{{href}}" class="{{class}}">{{text}}</a></li>
+                                                               <li><a 
href="{{href}}" class="{{stringOrArray class}}">{{text}}</a></li>
                                                        {{/each}}
                                                </ul>
                                        </li>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4b0178b7f01282e1a766ffce9159f0c68f1d190a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/skins/Blueprint
Gerrit-Branch: master
Gerrit-Owner: Spage <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: VolkerE <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to