mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-09-23 10:21:45 +00:00
[BREAKING CHANGE] Change default format to null instead of 'inline'
Don't enforce 'inline' as the default format if none is specified. Instead preserve the unspecified value as 'null'. This allows third-party tools to provide a better default experience when changing existing content (e.g. by using smart detection to follow the format already used). Bug: T128337 Change-Id: I911c7999e3731c0125fc058118f8d7287d8f88f4
This commit is contained in:
parent
97f1b8797e
commit
8e55adab59
|
@ -98,12 +98,12 @@ Consumers that look for a `Map` SHOULD publicly document their identifier key.
|
|||
Authors MUST ensure that the `maps` object contains only `Map` objects. Authors MAY include a parameter in multiple `Map` objects. Authors are NOT REQUIRED to reference each parameter in at least one `Map` object.
|
||||
|
||||
#### 3.1.6 `format`
|
||||
* Value: `string` of either `inline` or `block`
|
||||
* Default: `inline`
|
||||
* Value: `null` or `string` of either `'inline'` or `'block'`
|
||||
* Default: `null`
|
||||
|
||||
How the template's wikitext representation SHOULD be laid out. Authors MAY choose to use this parameter to express that a template will be better understood by other human readers of the wikitext representation if a template is in one form or the other.
|
||||
|
||||
If the parameter is set to `block`, Consumers SHOULD create a wikitext representation with a single newline after the template invocation and each parameter value, a single space between each pipe and its subsequent parameter key, and a space either side of the assignment separator between the parameter key and value, like so:
|
||||
If the parameter is set to `'block'`, Consumers SHOULD create a wikitext representation with a single newline after the template invocation and each parameter value, a single space between each pipe and its subsequent parameter key, and a space either side of the assignment separator between the parameter key and value, like so:
|
||||
|
||||
```
|
||||
{{Foo
|
||||
|
@ -112,13 +112,15 @@ If the parameter is set to `block`, Consumers SHOULD create a wikitext represent
|
|||
}}
|
||||
```
|
||||
|
||||
If the parameter is set to `inline`, Consumers SHOULD create a wikitext representation with no whitespace, like so:
|
||||
If the parameter is set to `'inline'`, Consumers SHOULD create a wikitext representation with no whitespace, like so:
|
||||
|
||||
```
|
||||
{{Foo|bar=baz|qux=quux}}
|
||||
```
|
||||
|
||||
In the absence of the parameter being set, the system will supply `inline` as a fallback value. Authors are RECOMMENDED to set `inline` explicitly if they actively chose to use the template that way.
|
||||
If the parameter is set to `null`, Consumers SHOULD create the same representation as for `'inline'` format for new template transclusions, and SHOULD attempt to use the same formatting for new parameters as for existing ones for existing transclusions that are edited.
|
||||
|
||||
In the absence of the parameter being set, the system will supply `null` as a fallback value.
|
||||
|
||||
### 3.2 Param
|
||||
* Value: `Object`
|
||||
|
|
|
@ -61,7 +61,7 @@ class TemplateDataBlob {
|
|||
$tdb->data->description = null;
|
||||
$tdb->data->params = new stdClass();
|
||||
$tdb->data->paramOrder = array();
|
||||
$tdb->data->format = 'inline';
|
||||
$tdb->data->format = null;
|
||||
$tdb->data->sets = array();
|
||||
$tdb->data->maps = new stdClass();
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class TemplateDataBlob {
|
|||
);
|
||||
|
||||
static $formats = array(
|
||||
null,
|
||||
'block',
|
||||
'inline'
|
||||
);
|
||||
|
@ -176,7 +177,7 @@ class TemplateDataBlob {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
$data->format = 'inline';
|
||||
$data->format = null;
|
||||
}
|
||||
|
||||
// Root.params
|
||||
|
@ -723,17 +724,19 @@ class TemplateDataBlob {
|
|||
array(),
|
||||
wfMessage( 'templatedata-doc-params' )->inLanguage( $lang )->text()
|
||||
)
|
||||
. Html::rawElement(
|
||||
'p',
|
||||
array(),
|
||||
new OOUI\IconWidget( array( 'icon' => 'template-format-' . $data->format ) )
|
||||
. Html::element(
|
||||
'span',
|
||||
array( 'class' => 'mw-templatedata-format' ),
|
||||
// Messages: templatedata-modal-format-inline, templatedata-modal-format-block
|
||||
wfMessage( 'templatedata-doc-format-' . $data->format )->inLanguage( $lang )->text()
|
||||
)
|
||||
)
|
||||
. ( $data->format !== null ?
|
||||
Html::rawElement(
|
||||
'p',
|
||||
array(),
|
||||
new OOUI\IconWidget( array( 'icon' => 'template-format-' . $data->format ) )
|
||||
. Html::element(
|
||||
'span',
|
||||
array( 'class' => 'mw-templatedata-format' ),
|
||||
// Messages: templatedata-modal-format-inline, templatedata-modal-format-block
|
||||
wfMessage( 'templatedata-doc-format-' . $data->format )->inLanguage( $lang )->text()
|
||||
)
|
||||
) :
|
||||
'' )
|
||||
)
|
||||
. '<thead><tr>'
|
||||
. Html::element(
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
"templatedata-modal-errormsg-import-noparams",
|
||||
"templatedata-modal-format-inline",
|
||||
"templatedata-modal-format-block",
|
||||
"templatedata-modal-format-null",
|
||||
"templatedata-modal-json-error-replace",
|
||||
"templatedata-modal-notice-import-numparams",
|
||||
"templatedata-modal-placeholder-paramkey",
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
"templatedata-modal-errormsg-import-noparams": "No new parameters found during import.",
|
||||
"templatedata-modal-format-inline": "Inline",
|
||||
"templatedata-modal-format-block": "Block",
|
||||
"templatedata-modal-format-null": "Unspecified",
|
||||
"templatedata-modal-json-error-replace": "Replace",
|
||||
"templatedata-modal-notice-import-numparams": "$1 new {{PLURAL:$1|parameter was|parameters were}} imported: $2",
|
||||
"templatedata-modal-placeholder-paramkey": "Parameter name",
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
"templatedata-modal-errormsg-import-noparams": "Error message that appears in the TemplateData generator GUI in case no template parameters were found during the import attempt.",
|
||||
"templatedata-modal-format-inline": "Label for inline format\n{{Identical|Inline}}",
|
||||
"templatedata-modal-format-block": "Label for block format\n{{Identical|Block}}",
|
||||
"templatedata-modal-format-null": "Label for null format",
|
||||
"templatedata-modal-json-error-replace": "Label for the button in the error message, agreeing to replace the existing faulty TemplateData string with a new one.\n{{Identical|Replace}}",
|
||||
"templatedata-modal-notice-import-numparams": "Message that appears in the TemplateData generator GUI showing how many new parameters were imported into the GUI from an existing template.\n\nParameters:\n* $1 - number of parameters\n* $2 - list of parameters that were imported",
|
||||
"templatedata-modal-placeholder-paramkey": "Placeholder for the input that contains new parameter name in the add parameter panel in the edit dialog.",
|
||||
|
|
|
@ -17,7 +17,7 @@ mw.TemplateData.Model = function mwTemplateDataModel( config ) {
|
|||
this.params = {};
|
||||
this.description = {};
|
||||
this.paramOrder = [];
|
||||
this.format = 'inline';
|
||||
this.format = null;
|
||||
this.paramOrderChanged = false;
|
||||
this.paramIdentifierCounter = 0;
|
||||
this.originalTemplateDataObject = null;
|
||||
|
@ -278,7 +278,7 @@ mw.TemplateData.Model.static.newFromObject = function ( tdObject, paramsInSource
|
|||
model.setTemplateParamOrder( tdObject.paramOrder );
|
||||
}
|
||||
|
||||
if ( tdObject.format ) {
|
||||
if ( tdObject.format !== undefined ) {
|
||||
model.setTemplateFormat( tdObject.format );
|
||||
}
|
||||
|
||||
|
@ -573,12 +573,12 @@ mw.TemplateData.Model.prototype.setTemplateParamOrder = function ( orderArray )
|
|||
/**
|
||||
* Set template format.
|
||||
*
|
||||
* @param {string} [format='inline'] Preferred format
|
||||
* @param {string|null} [format=null] Preferred format
|
||||
* @fires change-format
|
||||
* @fires change
|
||||
*/
|
||||
mw.TemplateData.Model.prototype.setTemplateFormat = function ( format ) {
|
||||
format = format || 'inline';
|
||||
format = format !== undefined ? format : null;
|
||||
if ( this.format !== format ) {
|
||||
this.format = format;
|
||||
this.emit( 'change-format', format );
|
||||
|
@ -651,7 +651,7 @@ mw.TemplateData.Model.prototype.getTemplateParamOrder = function () {
|
|||
/**
|
||||
* Retrieve the template preferred format
|
||||
*
|
||||
* @return {string} Preferred format
|
||||
* @return {string|null} Preferred format
|
||||
*/
|
||||
mw.TemplateData.Model.prototype.getTemplateFormat = function () {
|
||||
return this.format;
|
||||
|
|
|
@ -161,6 +161,10 @@ mw.TemplateData.Dialog.prototype.initialize = function () {
|
|||
data: 'block',
|
||||
icon: 'template-format-block',
|
||||
label: mw.msg( 'templatedata-modal-format-block' )
|
||||
} ),
|
||||
new OO.ui.ButtonOptionWidget( {
|
||||
data: null,
|
||||
label: mw.msg( 'templatedata-modal-format-null' )
|
||||
} )
|
||||
] );
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -105,7 +105,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["foo"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps": {}
|
||||
}
|
||||
',
|
||||
|
@ -138,7 +138,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["comment"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps": {}
|
||||
}
|
||||
',
|
||||
|
@ -188,7 +188,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["nickname"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps": {}
|
||||
}
|
||||
',
|
||||
|
@ -250,7 +250,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["1d", "2d"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -375,7 +375,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": ["bar", "quux"]
|
||||
}
|
||||
],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps": {}
|
||||
}',
|
||||
'status' => true
|
||||
|
@ -427,7 +427,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["bar"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -507,7 +507,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"description": "' . self::generatePseudorandomString( 100000, 42 ) . '",
|
||||
"params": {}
|
||||
}',
|
||||
'status' => 'Data too large to save (75,230 bytes, limit is 65,535)'
|
||||
'status' => 'Data too large to save (75,226 bytes, limit is 65,535)'
|
||||
),
|
||||
);
|
||||
$calls = array();
|
||||
|
@ -580,7 +580,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"sets": [],
|
||||
"maps": {},
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"paramOrder": []
|
||||
}';
|
||||
} else {
|
||||
|
@ -673,7 +673,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -691,7 +691,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"paramOrder": [],
|
||||
"params": {},
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -713,7 +713,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -734,7 +734,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -756,7 +756,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -793,7 +793,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["foo"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -830,7 +830,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["foo"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -867,7 +867,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["foo"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -913,7 +913,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": ["foo"]
|
||||
}
|
||||
],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps": {}
|
||||
}
|
||||
',
|
||||
|
@ -1013,7 +1013,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["foo", "bar", "baz"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -1071,7 +1071,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
},
|
||||
"paramOrder": ["baz", "foo", "bar"],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
@ -1100,7 +1100,7 @@ class TemplateDataBlobTest extends MediaWikiTestCase {
|
|||
"params": {},
|
||||
"paramOrder": [],
|
||||
"sets": [],
|
||||
"format": "inline",
|
||||
"format": null,
|
||||
"maps" : {}
|
||||
}
|
||||
',
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
format: 'inline'
|
||||
format: null
|
||||
};
|
||||
finalJson.description[ currLanguage ] = 'Label unsigned comments in a conversation.';
|
||||
|
||||
|
@ -629,7 +629,7 @@
|
|||
'}</templatedata>',
|
||||
simpleTemplateDataDefaultFormat = {
|
||||
params: {},
|
||||
format: 'inline'
|
||||
format: null
|
||||
};
|
||||
|
||||
QUnit.expect( 1 );
|
||||
|
|
Loading…
Reference in a new issue