Last modified: 2013-07-15 06:20:30 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T51743, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49743 - TemplateData doesn't let you have conditional meanings of parameters based on other parameters
TemplateData doesn't let you have conditional meanings of parameters based on...
Status: RESOLVED WONTFIX
Product: MediaWiki extensions
Classification: Unclassified
TemplateData (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-18 10:44 UTC by Mr. Stradivarius
Modified: 2013-07-15 06:20 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Mr. Stradivarius 2013-06-18 10:44:15 UTC
Templates behave differently depending on whether positional parameters are explicitly declared or not. For example, for [[Template:User]] on the English Wikipedia, {{user|1=foo=bar}} will return user links for the user "foo=bar", but {{user|foo=bar}} will generate an error, as there is no "foo" parameter. However, there does not seem to be any way of distinguishing explicit positional parameters from implicit positional parameters using TemplateData. I am guessing that this ability will be needed for the Visual Editor to properly handle existing templates - see also bug 49739.
Comment 1 James Forrester 2013-07-09 20:55:32 UTC
I'm sorry, I've read this a dozen times and I still don't understand what you think we should change. Could you re-state?
Comment 2 James Forrester 2013-07-12 16:31:44 UTC
Closing for now; please re-open if you can help us identify the issue here.
Comment 3 Richard Morris 2013-07-13 10:23:03 UTC
Here is an example I'm not sure about. For {{coord}}
http://en.wikipedia.org/wiki/Template:Coord/doc
the template can have two main forms

Hours Minute Seconds {{Coord|57|18|22|N|4|27|32|W|display=inline}}

Decimal Degrees {{coord|43.6500|-79.3800|display=inline}}

In the first the Longitude degrees is the 5th parameter, in the second its the 2nd parameter. I've tried some sample template data at http://en.wikipedia.org/wiki/Template:Coord/doc#Template_Data
with documentation for Longitude degrees as the 5th parameter.

What I'm not sure about is how this will work with the second form. Will VE create {{coord|1=43.6500|5=-79.3800|display=inline}} which will badly mess up
giving an "Coordinates: Unknown argument format" error. Or will it play nice and produce {{coord|43.6500|-79.3800|display=inline}}?

Here I require the positional parameter to be silent, that is implicit, not giving the number. 

There are cases where if the parameter value contains a = that you need to explicitly state the position parameter. Compare the results of {{math|foo=bar}}
with {{math|1=foo=bar}} (on en.wp). Here you need to explicitly give the parameter.

<templatedata>{
"description": "Encodes the latitude and longitude coordinates of a location, provides a link to map of the location.",
"params": {
  "1": {
    "label": "Latitude degrees",
    "description": "The degrees part of the latitude. This can either be a whole number in which case minutes and seconds can also be provided in subsequent parameters, or in decimal format, negative for south eg -79.38.",
    "type": "number",
    "required": true
  },
  "2": {
    "label": "Latitude minutes",
    "description": "The minutes part of the latitude. Do not be overly precise, 1' is approximately 1.5km, Not used if decimal degrees are specified.",
    "type": "number",
    "required": false
  },
  "3": {
    "label": "Latitude seconds",
    "description": "The minutes part of the latitude. Do not be overly precise,  1\" is approximately 30m. Not used if decimal degrees are specified.",
    "type": "number",
    "required": false
  },
  "4": {
    "label": "Latitude direction",
    "description": "Direction part of latitude: N or S. Not used if decimal degrees are specified.",
    "type": "string",  
    "required": false
  },
  "5": {
    "label": "Longitude degrees",
    "description": "The degrees part of the longitude. This can either be a whole number in which case minutes and seconds can also be provided in subsequent parameters, or in decimal format, negative for west eg -79.38.",
    "type": "number",
    "required": true
  },
  "6": {
    "label": "Longitude minutes",
    "description": "The minutes part of the longitude. Do not be overly precise 1' is approximately 1.5km. Not used if decimal degrees are specified.",
    "type": "number",
    "required": false
  },
  "7": {
    "label": "Longitude seconds",
    "description": "The minutes part of the longitude. Do not be overly precise 1\" is approximately 30m. Not used if decimal degrees are specified.",
    "type": "number",
    "required": false
  },
  "8": {
    "label": "Longitude direction",
    "description": "Direction part of longitude: E or W. Not used if decimal degrees are specified.",
    "type": "string",  
    "required": false
  },
  "9": {
    "label": "Coordinate parameters",
    "description": "Optional parameters separated by an underscore '_', dim:N (viewing diameter in metres), region:R (ISO 3166-1 alpha-2 or ISO 3166-2 code), type:T (eg landmark or city(30,000)). For example 'dim:30_region:US-WI_type:event'",
    "type": "string",  
    "required": false
  },
  "display": {
    "label": "Display",
    "description": "Where it is displayed. Can be one of: 'inline' in the body of the article (default), 'title' at the top of the article or 'inline,title' both",
    "type": "string",  
    "required": false
  },
  "name": {
    "label": "Name",
    "description": "a label to place on maps (default is PAGENAME)",
    "type": "string",  
    "required": false
  },
  "notes": {
    "label": "Notes",
    "description": "text displayed immediately following the coordinates",
    "type": "string",  
    "required": false
  },
  "format": {
    "label": "Format",
    "description": "How the coordinates are displayed, either 'dec' or 'dms'",
    "type": "string",  
    "required": false
  }
}}</templatedata>
Comment 4 James Forrester 2013-07-15 01:34:49 UTC
You are right, this is a mess - because this is a template that is broken by design.

The TemplateData you have written in comment 3 is wrong - most notably:

  "2": {
    "label": "Latitude minutes",
    "description": "The minutes part of the latitude. Do not be overly precise,
1' is approximately 1.5km, Not used if decimal degrees are specified.",
    "type": "number",
    "required": false
  },


This is not true. "2" is "either Latitude minutes or Longitude decimal depending on other parameters". Both meanings of the second positional parameter can be used implicitly - hence my confusion. Have re-named to "TemplateData doesn't let you have conditional meanings of parameters based on other parameters" which I think captures the issue best?

In general, this is simply an example of a ridiculously-confusing template for users. I'd very strongly recommend just fixing the template (by splitting the two users into different templates; use a single parent template to implement the proper RDFa hinting equivalently).

Otherwise, I can't see what resolution you'd expect us to come up with - descriptions that change depending on the phase of the moon? TemplateData does not, and will not, contain conditionality in its definitions.
Comment 5 Richard Morris 2013-07-15 06:20:30 UTC
Its a template used on 863,827 pages, so I guess people have been able to use it just fine. Its not broken by design its just a template which makes heavy use of http://en.wikipedia.org/wiki/Function_overloading  which differs by the arity of its arguments, a well used software design practice. The problem is that the templatedata systems does not allow for this paradigm.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links