Vorlage:TemplateData: Unterschied zwischen den Versionen

Aus Cowboy's Wiki
Wechseln zu: Navigation, Suche
K
K
 
Zeile 1: Zeile 1:
{{TemplateDataInfo}}
+
<onlyinclude><div class="Vorlage_TemplateData" style="border:2px solid #b3b7ff; margin:1em 0; padding:.5em 1em 0; position:relative;">
 
+
<div class="hintergrundfarbe2" style="left:2em; line-height:1; padding:0 .5em; position:absolute; top:-.6em;"><small>[[Hilfe:TemplateData|TemplateData]]</small></div>
== Using [[Template:TemplateBox|TemplateBox]] ==
+
{{{1}}}
<onlyinclude>
+
</div><includeonly>{{#ifeq:{{NAMESPACENUMBER}}|10|{{#ifeq:{{#titleparts:{{PAGENAME}}|1|-1}}|Doku||[[Kategorie:Vorlage:mit TemplateData|{{#if:{{{sort|}}}|{{{sort}}}|{{PAGENAME}}}}]]}}}}</includeonly></onlyinclude>
Every entity, except '''inherit''' that is documented at [[:mw:Extension:TemplateData|the TemplateData technical documentation]], is supported by {{tl|TemplateBox}}. Conversion to JSON is done by a LUA module. The LUA module automatically converts traditionally used parameters as well as the new ones to both, TemplateData, as well as the "historic table", on demand. The "historic table" is the table which was used to show parameter information at Wikimedia Commons before TemplateData was invented.
+
{{Dokumentation}}
 
 
;Required parameters
 
* <code><nowiki>|desc=</nowiki></code> (or in its translated form), parameters and their description
 
 
 
{{Anker|Translation}}
 
;Translation
 
* Avoid {{tl|LangSwitch}}. It doesn't work in TemplateData.
 
* Append [[:en:ISO 639-1|<code><nowiki>-langcode</nowiki></code>]] to the name of any translatable parameter, marked by {{TemplateBox/use suffix}} in [[Template:TemplateBox#Parameters|TemplateBox]]. For example, adding the French translation of the description of parameter 1, you would write <code><nowiki>|1d-fr=C'est la description pour paramètre un.</nowiki></code>. Supplying only <code><nowiki>|1d-en=This is the description of parameter 1.</nowiki></code> instead of <code><nowiki>|1d=This is the description of parameter 1.</nowiki></code> will also work. The <code><nowiki>-en</nowiki></code>-style is recommended because it eases the job for translators. They then recognize the structure behind it without having to consult the documentation.
 
* The language code must be the last element. Valid: <code><nowiki>|1d-td-en=</nowiki></code>. Invalid: <s><code><nowiki>|1d-en-td=</nowiki></code></s>
 
 
 
;Naming
 
* Both, old names and new names are supported but treated differently if both of them are supplied.
 
** For example, while creating the "historic table", if both <code><nowiki>1def</nowiki></code> and <code><nowiki>1default</nowiki></code> where supplied, the value for <code><nowiki>1def</nowiki></code> would be used. For generating TemplateData, the preference is the other way around.
 
 
 
;Overriding
 
* It's possible to override a specific entity, either for the "historic table" or for TemplateData.
 
** To override for TemplateData, append a <code><nowiki>-td</nowiki></code> to the parameter's default name.
 
** On the other hand, if you coded something for TemplateData and want to use a link or other markup in the "historic table", use the parameter name without the <code><nowiki>-td</nowiki></code> or modify that, which should be only used for TemplateData appending <code><nowiki>-td</nowiki></code>.
 
 
 
;Pay attention:
 
* TemplateData does not support parsing Wiki-Markup. Think of it as if it would expand all templates and finally putting a nowiki around all this.
 
* When including templates, they must be wrapped them in <code><nowiki><nowiki></nowiki></code>s, ''if they should not be expanded'' (it's, on the other hand, a geeky feature that you can use, if having the expanded content inside TemplateData is exactly what you ''want'').
 
* Even though some tags, such as <code><nowiki><pre></nowiki></code> seem to be rendered as expected, avoid them.
 
 
 
;Activation:
 
* TemplateData can be activated setting the <code><nowiki>useTemplateData</nowiki></code> parameter to <code><nowiki>1</nowiki></code> or to <code><nowiki>only</nowiki></code>. The former will add a collapsed version of the table; the latter one replaces the "historic table" with the TemplateData table. In both cases, TemplateData is available through the API.
 
 
 
;Fetching TemplateData (e.g. for TemplateBox itself)
 
[//commons.wikimedia.org/wiki/Special:ApiSandbox#action=templatedata&format=json&titles=Template%3ATemplateBox /w/api.php?action=templatedata&format=json&titles=Template%3ATemplateBox] ([//commons.wikimedia.org/w/api.php?action=templatedata&format=json&titles=Template%3ATemplateBox raw result], [//commons.wikimedia.org/w/api.php?action=templatedata&format=jsonfm&titles=Template%3ATemplateBox pretty result])
 
 
 
;Advantages:
 
* No type-mixture: Instead of inserting a new content-type, a template can be used.
 
* Syntax: Less error-prone compared to editing JSON (without a special editor).
 
* Schema: Always valid. TemplateBox always passes a structure matching the requested schema.
 
* Flat structure.
 
* Prepared for future changes. Adjustments to the LUA module can be made to support future changes. The power of control remains at Commons.
 
* Inserting redundant information can be avoided.
 
* Template traditionally used at Commons.
 
 
 
;Issues:
 
* Grouping sets is currently not supported in the "historic table". Set labels are not supported to be multilingual (ideas how one could achieve this are truly welcome).
 
 
 
;Example:
 
<pre style="overflow:auto;">
 
{{TemplateBox
 
 
 
  | useTemplateData = 1
 
  | 1 = artist
 
  | 1aliases = Artist
 
  | 1label-en = Artist
 
  | 1type = string
 
 
 
  <!-- used as the parameter description in the main parameter area of the documentation -->
 
  <!-- and in the template data section unless overridden with 1d-td-langcode --> 
 
  | 1d-de = Künstler, der das ursprüngliche Kunstwerk geschaffen hat.<br/>Benutze möglichst immer <nowiki>{{Creator:Vorname Nachname}}</nowiki> mit der Vorlage {{Tl|Creator}}.
 
  | 1d-en = Artist who created the original artwork.<br/>Use <nowiki>{{Creator:Name Surname}}</nowiki> with {{Tl|Creator}} template whenever possible.
 
  | 1d-fr = Artiste ou artisan à l'origine de l'œuvre.<br/>Dans la mesure du possible, utiliser le modèle {{Tl|Creator}}.
 
  | 1d-sv = Artist som skapade originalverket.<br/>Använd <nowiki>{{Creator:Förnamn Efternamn}}</nowiki> med {{Tl|Creator}}-mallen om detta är möjligt.
 
 
 
  <!-- this overrides 1d-en in the Template data section -->
 
  <!-- and all other translations unless each is provided as desc-td-langcode -->
 
  | 1d-td-en = Artist who created the original artwork; this overrides "1d-en" in the Template data section; "1d-en" is used in the template "Parameter" section.
 
 
 
  | 1def-de = Freifeld, angezeigt als: "{{int:wm-license-information-author}}".
 
  | 1def-en = blank field presented as: "{{int:wm-license-information-author}}".
 
  | 1def-fr = champ vide: « {{int:wm-license-information-author}} »
 
  | 1def-sv = tomt fält, visas som: "{{int:wm-license-information-author}}"
 
 
 
  <!-- used as the description of the template in the main documentation area -->
 
  <!-- and in the Template data section unless overridden with desc-td-langcode -->
 
  | desc-de = Deutsche Übersetzung der {{tl|Vorlagen}}beschreibung
 
  | desc-en = English translation of the {{tl|template}} description
 
 
 
  <!-- this overrides desc-en in the Template data section -->
 
  <!-- and all other translations unless each is provided as desc-td-langcode -->
 
  | desc-td-en = English translation that is used in the Template data section instead of "desc-en". This will also replace all desc-langcode translations, unless corresponding "desc-td-langcode" is provided.
 
 
 
}}
 
</pre>
 
A live example is [[Template:Information/doc]] ([//commons.wikimedia.org/w/index.php?title=Template%3AInformation%2Fdoc&diff=102133596&oldid=101526770 edit that enabled TemplateData through TemplateBox], [//commons.wikimedia.org/w/api.php?action=templatedata&format=jsonfm&titles=Template%3AInformation API-result showing the JSON generated by the Lua Module behind TemplateBox])
 
 
 
;Experimenting:
 
You can use [[Special:ExpandTemplates]] to experiment with how the template will output the template documentation and the Template data section; e.g., copy the example above and paste it into the input text on the [[Special:ExpandTemplates]] page; then click on the ok button to see the result.
 
</onlyinclude>
 
 
 
[[Category:Commons help]]
 

Aktuelle Version vom 12. Oktober 2014, 23:22 Uhr

{{{1}}}


Dokumentation[Bearbeiten]

Hinweis für Dokumentationsseiten von Vorlagen auf TemplateData-Generierung

Vorlagenparameter

ParameterBeschreibungTypStatus
JSON-Code1

Quelltext des JSON-Objekts, eingeschlossen in -Tags

Standard
leer
Beispiel
leer
Autowert
leer
Zeichenfolgeerforderlich
Sortierschlüsselsort

Abweichend vom Titel der Vorlage; namentlich für Demonstrationszwecke

Standard
Titel der Vorlage
Beispiel
leer
Autowert
leer
Zeichenfolgeoptional

Um einen besseren Überblick als mit Special:PagesWithProp/templatedata möglich zu erhalten, werden die Einbindungen vermerkt in:


Bei Fragen zu dieser Vorlage kannst du dich an die Vorlagenwerkstatt wenden.