Difference between revisions of "User:Philmasterplus/TemplateSandbox"

From Kolmafia
Jump to navigation Jump to search
Line 1: Line 1:
<includeonly><div><code style="white-space: pre">{{msgnw:{{FULLPAGENAME}}}}</code></div></includeonly><noinclude>This is a sandbox for testing wiki templates.</noinclude>
+
<includeonly>{{{1|{{{error|Missing parameter '1' for Template:Data}}}}}}{{{2|{{{error|Missing parameter 'field' for Template:Data}}}}}}
 +
{{#ifexist:{{{1}}}
 +
|{{
 +
  {{{1}}}
 +
  |format=#switch:{{{2}}}
 +
  |{{{3}}}
 +
}}
 +
|{{{error|Page '{{{1}}}' does not exist in Template:Data}}}
 +
}}</includeonly>
 +
<noinclude>
 +
<templatedata>
 +
{
 +
  "description": "Utility template that extracts a field from a specially formatted page.",
 +
  "params": {
 +
    "1": {
 +
      "label": "Page name",
 +
      "description": "Name of the source page to extract the data from. The source page is evaluated as a #switch-statement.",
 +
      "type": "wiki-page-name",
 +
      "required": true,
 +
      "example": "visit_url"
 +
    },
 +
    "2": {
 +
      "label": "Field name",
 +
      "description": "Field name to extract from the source page.",
 +
      "type": "line",
 +
      "required": true,
 +
      "example": "function1.parameter1"
 +
    },
 +
    "3": {
 +
      "label": "Default value",
 +
      "description": "Default value if the page does not contain the given field",
 +
      "type": "string",
 +
      "example": "no_name"
 +
    }
 +
  }
 +
}
 +
</templatedata>
 +
 
 +
This template is similar to [https://kol.coldfront.net/thekolwiki/index.php/Template:Data Template:Data] in the KoL Coldfront Wiki.
 +
</noinclude>

Revision as of 14:30, 18 December 2020


Utility template that extracts a field from a specially formatted page.

Template parameters

ParameterDescriptionTypeStatus
Page name1

Name of the source page to extract the data from. The source page is evaluated as a #switch-statement.

Example
visit_url
Pagerequired
Field name2

Field name to extract from the source page.

Example
function1.parameter1
Linerequired
Default value3

Default value if the page does not contain the given field

Example
no_name
Stringoptional

This template is similar to Template:Data in the KoL Coldfront Wiki.