Extension:TemplateData/hi

TemplateData एक्सटेंशन एक टैग और API प्रदान करता है जो साथ मिलकर सदस्यों को यह निर्दिष्ट करने देते हैं कि साँचों को कैसे इन्वोक किया जाएगा। यह जानकारी एंड-सदस्यों के लिए एक सुंदर टेबल के रूप में उपलब्ध है, और साथ में एक JSON API के रूप में भी (जैसे VisualEditor) जिससे साँचों और उनके पैरामीटरों के साथ काम करने के लिए इंटरफ़ेस बनाए जा सकते हैं। विस्तृत सहायता के लिए देखें।

स्थापना


डेटा को सम्पादित करना
TemplateData एक्सटेंशन किसी साँचा पृष्ठ के विकिटेक्स्ट में परिभाषित टैग की मदद से काम करता है (जिसे वैकल्पिक रूप से किसी दूसरे पृष्ठ से ट्रांसक्लूड भी किया जा सकता है)। इसे उन कई विकियों के साधारण लेआउट से मेल खाने के लिए बनाया गया है जो एक दूसरे पृष्ठ से साँचा प्रलेख को ट्रांसक्लूड करते हैं (मगर यह आवश्यक नहीं)। टैग की सामग्री को नीचे के वर्णित प्रारूप के साथ एक मान्य JSON होना होगा; ध्यान रखें कि सभी विवरणों को सादे टेक्स्ट में होना होगा (साँचा डेटा में विकिटेक्स्ट स्वीकृत नहीं)।

जब पृष्ठ पर एक ब्लॉक जोड़ दिया जाता है, तब पृष्ठ के सहेजने पर TemplateData एक्सटेंशन निम्न जाँच पूरे करता है:


 * 1) The contents must be valid JSON;
 * 1) Each item within the JSON structure must be of the expected type as specified below (e.g. object, array, or a primitive); and
 * 1) For those items which have a specified list of possible values (e.g.  ), the value in the JSON object must match one of those values.

If any of these checks fails, the server will not be permitted saving and an error message will be displayed above the edit page.

For autovalue items, bug 2700 prevents  from working in any template that is added inside a, including  and  tags. The TemplateData block will save correctly, but the resulting wikitext will not be parsed correctly when the template is used.

Note that  you cannot use  in lieu of.

Format
The below is a visualised version of the JSON data as defined on the template page enclosed by  tags. The formal specification is available in the TemplateData repository. Refer to Specification.md for the latest version.

TemplateData object
The TemplateData object is a JSON root element enclosed in a element on the template page.

InterfaceText (string or object)
A free-form plain-text string (i.e. no wikitext or HTML) in the content-language of the wiki, or an object containing those strings keyed by language code.

The default value for all InterfaceText fields is.

String type
If it is a string, it must contain a non-localized string in the content language of the local wiki.

Object type
If it is an object, the object must have this mapping:

Example
An example TemplateData structure as specified within wikitext on a template page.

Below is how the above example would be displayed on the template page:

{   "description": "Label unsigned comments in a conversation.", "params": { "user": { "label": "User's name", "type": "wiki-user-name", "required": true, "description": "User name of person who forgot to sign their comment.", "aliases": ["1"] },       "date": { "label": "Date", "suggested": true, "description": { "en": "Timestamp of when the comment was posted, in YYYY-MM-DD format." },           "aliases": ["2"], "autovalue": "" },       "year": { "label": "Year", "type": "number" },       "month": { "label": "Month", "inherits": "year" },       "day": { "label": "Day", "inherits": "year" },       "comment": { "required": false }   },    "sets": [ {           "label": "Date", "params": ["year", "month", "day"] }   ],    "maps": { "ExampleConsumer": { "foo": "user", "bar": ["year", "month", "day"], "quux": [ "date", ["day", "month"], ["month", "year"], "year" ]       }    } }

API
See the generated help at Special:ApiHelp/templatedata. A sample invocation (formatted for human readability) is:

This returns the template data for Template:Cite web. The  block for this template is on its transcluded template documentation page, en:Template:Cite web/doc.

Additions and changes to JSON as received from the API
The JSON structure provided in response to an API HTTP get request is significantly different than that which is defined in the  block. In response to the API request, extension TemplateData makes the following changes to the JSON object:


 * Adds two wrapping objects:
 * An overall Pages Object containing one or more Page Objects
 * An object with a numeric key: a Page Object
 * Additions/changes to the actual TemplateData Object
 * Add the  key with the name of the page from which the data was requested (e.g. "Template:Cite web").
 * Add the  key
 * Change all TemplateText occurrences that are just strings to objects with a single key for the current wiki's Wikipedia language code
 * Remove all  keys.
 * Add all properties from parameter from which an inheritance is defined which are not superseded by explicitly defined keys in the inheritor's Parameter Object.
 * Add default values for all keys in each Parameter Object which have not been explicitly defined or inherited.

Example of JSON object provided by API
The response to an API request for the TemplateData structure in the Example section (above) can be seen:
 * In HTML format: https://www.mediawiki.org/w/api.php?action=templatedata&titles=Extension:TemplateData&format=jsonfm
 * As delivered by the API: https://www.mediawiki.org/w/api.php?action=templatedata&titles=Extension:TemplateData

कॉन्फ़िगरेशन


ये भी देखें

 * – user interface for selecting and inserting templates' wikitext, based on their TemplateData.
 * GitHub: jeblad/TemplateData – alternate version with some Lua functionality.
 * Translatable template
 * Wikibase/Maps_TemplateData