Extension:TemplateData/he

התוסף TemplateData מציג תג וממשק API, שאיתם עורכים ידעו איך להשתמש בתבניות. מידע זה זמין כטבלה בפורמט יפה עבור משתמשי קצה, וכ-JSON API, המאפשר להשתמש דרך מערכות אחרות (כגון VisualEditor), וכן לבנות ממשקים עבור תבניות והפרמטרים שלהן. ראו לעזרה מעמיקה.

התקנה


עריכת מידע
התוסף TemplateData פועל באמצעות התג המוגדר בקוד המקור של הדף. This is designed to be compatible with the common layout many wikis have of transcluding template documentation from a separate page (but is not required). This content of the tag must be valid JSON using the format described below; note that all descriptions must be in plain text (no wikitext is accepted inside the template data).

When a block is included on a page, the TemplateData extension performs the following checks when the page is being saved:


 * 1) התוכן חייב להיות כתוב ב-JSON.
 * 2) כל פריט בתוך מבנה ה-JSON חייב להיות מהסוג כמפורט להלן (למשל אובייקט, מערך או פרימיטיבי).
 * 3) עבור אותם פריטים שלהם רשימה מוגדרת של ערכים אפשריים (לדוגמה,  ), הערך באובייקט JSON חייב להיות תואם לאחד מהערכים הללו.

אם אחת מהבדיקות הללו נכשלת, לא יתאפשר לבצע שמירה בדף שעליו בוצעה העריכה, וכן תוצג הודעת שגיאה מעל דף העריכה.

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.

פורמט
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
האובייקט TemplateData הוא שורש JSON המוקף באלמנט בדף התבנית.

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.



סוג מחרוזת
If it is a string, it must contain a non-localized string in the content language of the local wiki.



סוג אובייקט
If it is an object, the object must have this mapping:

דוגמה
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)
לעזרה בנושא ראו 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.

Visualised differences in a TemplateData JSON object delivered by the API


דוגמה לאובייקט JSON שמסופק על ידי API
ניתן לראות את אובייקט ה-JSON כפי שמסופר על ידי ה-API עבור המבנה TemplateData שמופיע בפסקה זו (מופיע למעלה):
 * בפורמט HTML ראו: https://www.mediawiki.org/w/api.php?action=templatedata&titles=Extension:TemplateData&format=jsonfm
 * כפי שמוצג על פי ה-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