Page MenuHomePhabricator

Provide a standard way to send messages to SkinMustache templates
Closed, ResolvedPublic

Description

It should be easier to send messages to the underlying mustache template with a predictable message key. This will solve two problems 1) making sure messages are always escaped correctly (not double escaped). 2) Make sure template keys map to mustache keys.

After experiments inside Monobook, CologneBlue, Modern and Vector I recommend we add this functionality to core. This is consistent with how we send messages to ResourceLoader modules.

This idea has been explored here:
https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/599972/19/includes/SkinVector.php

Acceptance criteria

  • A messages option is added to the SkinMustache constructor in core.
  • These messages are mapped to template keys inside getTemplateData. For example if messages = [ 'foo' ] the value of the message foo will be available to the template by referencing msg-foo.
  • Vector is updated to use the new capability inside SkinMustache

Sample code

$msgs = $this->options['messages'] ?? [];
		$msgData = [];
		foreach ( $msgs as $key ) {
			$msgData["msg-" . $key] = $this->msg( $key )->text();
		}

Event Timeline

Change 618489 had a related patch set uploaded (by Mainframe98; owner: Mainframe98):
[mediawiki/core@master] Skins: Have SkinMustache provide messages set in skin options

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

Change 618490 had a related patch set uploaded (by Mainframe98; owner: Mainframe98):
[mediawiki/skins/Vector@master] Provide messages through skin options

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

Change 618489 merged by jenkins-bot:
[mediawiki/core@master] Skins: Have SkinMustache provide messages set in skin options

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

Change 618490 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Provide messages through skin options

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