From c405ffb155ceda9b69b1e009c384a8f01464947b Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Fri, 10 Jul 2020 14:31:09 -0700 Subject: [PATCH] Cleanup: Template variables - Remove unused html-prebodyhtml template variable - Don't use html- prefixed variables as if statements - this is not supported by Mustache. (set to '' to confirm) Change-Id: I0c860b4b2277e1796afa3e482cf61e95ef4fb342 --- includes/VectorTemplate.php | 6 ++++-- includes/templates/skin-legacy.mustache | 12 +++--------- includes/templates/skin.mustache | 14 ++++---------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index f9319ae..eb35613 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -133,6 +133,9 @@ class VectorTemplate extends BaseTemplate { // // Conditionally used values must use null to indicate absence (not false or ''). $mainPageHref = Skin::makeMainPageUrl(); + // From Skin::getNewtalks(). Always returns string, cast to null if empty. + $newTalksHtml = $skin->getNewtalks() ?: null; + // @phan-suppress-next-line PhanUndeclaredMethod $commonSkinData = $skin->getTemplateData() + [ 'html-headelement' => $out->headElement( $skin ), @@ -144,8 +147,7 @@ class VectorTemplate extends BaseTemplate { 'html-title' => $out->getPageTitle(), 'msg-tagline' => $skin->msg( 'tagline' )->text(), - // From Skin::getNewtalks(). Always returns string, cast to null if empty. - 'html-newtalk' => $skin->getNewtalks() ?: null, + 'html-newtalk' => $newTalksHtml ? '
' . $newTalksHtml . '
' : '', 'msg-vector-jumptonavigation' => $skin->msg( 'vector-jumptonavigation' )->text(), 'msg-vector-jumptosearch' => $skin->msg( 'vector-jumptosearch' )->text(), diff --git a/includes/templates/skin-legacy.mustache b/includes/templates/skin-legacy.mustache index f94a83e..b2401b7 100644 --- a/includes/templates/skin-legacy.mustache +++ b/includes/templates/skin-legacy.mustache @@ -7,7 +7,6 @@ "featured article". An empty array if none are defined. string page-langcode the content language of the article. Assumed to be escaped HTML. string html-title - string html-prebodyhtml bool page-isarticle string msg-tagline string html-subtitle @@ -39,17 +38,14 @@
- {{#html-sitenotice}} -
{{{html-sitenotice}}}
- {{/html-sitenotice}} +
{{{html-sitenotice}}}
{{>Indicators}}

{{{html-title}}}

- {{{html-prebodyhtml}}}
{{#page-isarticle}}
{{msg-tagline}}
{{/page-isarticle}}
{{{html-subtitle}}}
- {{#html-undelete}}
{{{html-undelete}}}
{{/html-undelete}} - {{#html-newtalk}}
{{{html-newtalk}}}
{{/html-newtalk}} +
{{{html-undelete}}}
+ {{{html-newtalk}}} {{! Keep this empty `div` for compatibility with gadgets and user scripts using this place to insert extra elements before. @@ -58,9 +54,7 @@ {{msg-vector-jumptonavigation}} {{msg-vector-jumptosearch}} {{{html-bodycontent}}} - {{#html-printfooter}}
{{{html-printfooter}}}
- {{/html-printfooter}} {{{html-catlinks}}} {{{html-debuglog}}}
diff --git a/includes/templates/skin.mustache b/includes/templates/skin.mustache index 8d26205..64e1a34 100644 --- a/includes/templates/skin.mustache +++ b/includes/templates/skin.mustache @@ -7,7 +7,6 @@ "featured article". An empty array if none are defined. string page-langcode the content language of the article. Assumed to be escaped HTML. string html-title - string html-prebodyhtml bool page-isarticle string msg-tagline string html-subtitle @@ -57,17 +56,14 @@
- {{#html-sitenotice}} -
{{{html-sitenotice}}}
- {{/html-sitenotice}} +
{{{html-sitenotice}}}
{{>Indicators}}

{{{html-title}}}

- {{{html-prebodyhtml}}}
{{#page-isarticle}}
{{msg-tagline}}
{{/page-isarticle}}
{{{html-subtitle}}}
- {{#html-undelete}}
{{{html-undelete}}}
{{/html-undelete}} - {{#html-newtalk}}
{{{html-newtalk}}}
{{/html-newtalk}} +
{{{html-undelete}}}
+ {{{html-newtalk}}} {{! Keep this empty `div` for compatibility with gadgets and user scripts using this place to insert extra elements before. @@ -76,9 +72,7 @@ {{msg-vector-jumptonavigation}} {{msg-vector-jumptosearch}} {{{html-bodycontent}}} - {{#html-printfooter}} -
{{{html-printfooter}}}
- {{/html-printfooter}} +
{{{html-printfooter}}}
{{{html-catlinks}}} {{{html-debuglog}}}