Template:Data to Table

From Honkai: Nexus Anima Wiki
Revision as of 17:21, 10 October 2026 by ReisuDesign (talk | contribs) (Created page with "<includeonly>{{#invoke:Data to Table|main |info={{{info|}}} |keys={{{keys|}}} |unquoted={{{unquoted|}}} |block={{{block|}}} |sortkey={{{sortkey|}}} |subtable={{{subtable|}}} |cleanTT={{{cleanTT|}}} |value={{{value|}}} |json={{{json|}}} |copy={{{copy|}}} |group1={{{group1|}}} |group1_info={{{group1_info|}}} |group2={{{group2|}}} |group2_info={{{group2_info|}}} |group3={{{group3|}}} |group3_info={{{group3_info|}}} |group4={{{group4|}}} |group4_info={{{group4_info|}}}...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Documentation icon Template documentation
Note: parts of or the entire template might not be visible without values provided.
This template uses Module:Data to Table, a script written in Lua.

Lua module to allow users to create "copy-pastable" data tables based on custom DPL queries, as well as JSON data from DPL queries.

Syntax

  • info — The raw output of a DPL query (see usage examples).
  • keys — A ;;-separated list of keys to extract from the info. You can use nested levels with // and @@.
    • Note that although the page itself must be included in your DPL include statement, it is used as the table's key by default, so there is no need to specify it.
  • unquoted (optional) — A ;;-separated list of keys whose values should be output as raw Lua values instead of strings.
  • value (optional) — Sets the same value for every entry when no keys are specified.
  • sortkey (optional) — Specifies which key to sort the data by, using the page name by default. Use INPUT to preserve the original order.
  • subtable (optional) — Splits values into subtables.
  • block (optional) — Display the results using block formatting.
  • copy (optional) — Enter your header here. Adds a button to copy the generated Lua table to your clipboard at the top.
  • cleanTT (optional) — Auto-parse out any {{tt}} format in the output.

JSON Mode

  • json — Set to 1 to output JSON instead of a Lua table.
  • group1, group2, etc. — The name of a JSON group.
  • group1_info, group2_info, etc. — The DPL output used to populate the corresponding group.
    • Groups may be numbered sequentially up to group10.
    • Empty groups are automatically omitted from the generated JSON.
    • JSON mode uses the built-in copy button provided by the syntax highlighting extension.

When json is set to 1, the module supports both simple JSON arrays and grouped JSON objects.

Examples

Lua Table

A basic DPL query can be converted into a Lua data table:

{{Data to Table
|keys=number;;quality;;galaxy
|unquoted=number
|info={{#DPL:
|namespace=
|category=Fish
|uses=Template:Creature Infobox
|include={Creature Infobox}:%PAGE%,{Creature Infobox}:number,{Creature Infobox}:quality,{Creature Infobox}:distribution
|format=,,,
|secseparators=page==,;;number==,,;;quality==,,;;galaxy==,,$$$
}}
}}

This produces output in the following format: Template:Sh

Constant Values

value can be used when every entry should have the same value:

{{Data to Table
|value=day
|info={{#DPL:
|namespace=File
|category=Icons to Invert
|format=,page==%PAGE%$$$,,
}}
}}

This produces: Template:Sh

If the value should be output as a raw Lua value rather than a string, include value in unquoted.

Simple JSON Array

JSON mode can also be used without groups:

{{Data to Table
|json=1
|info={{#DPL:
|namespace=File
|category=Icons to Invert
|format=,page==%PAGE%$$$,,
}}
}}

This produces: Template:Sh

Grouped JSON

Multiple DPL queries can be combined into a single JSON object using groups:

{{Data to Table
|json=1

|group1=day
|group1_info={{#DPL:
|namespace=File
|category=Icons to Invert
|format=,page==%PAGE%$$$,,
}}

|group2=night
|group2_info={{#DPL:
|namespace=File
|category=Icons to Invert Night
|format=,page==%PAGE%$$$,,
}}
}}

This produces:

Template:Sh

Groups with no results are automatically omitted. For example, if the night category is empty, the output will simply be:

Template:Sh

Multiple Groups

Additional groups can be added by continuing the numbering:

|group1=day
|group1_info=...

|group2=night
|group2_info=...

|group3=special
|group3_info=...

Up to group10 / group10_info are supported.

DPL Formatting for JSON

When using JSON mode, each DPL query should output an entry using the page==...$$$ format.

For example:

|format=,page==%PAGE%$$$,,

The page value is used as the value in the JSON array.

For file categories, the resulting JSON can therefore contain the full filename, such as:

Template:Sh

rather than only the page title or the filename without its extension.

Notes

  • JSON output is sorted alphabetically by page name.
  • Lua output is sorted according to sortkey, which defaults to the page name.
  • JSON mode does not use Template:M; it uses the copy button provided by the syntax highlighting extension.
  • Normal Lua output can still use copy to add the custom copy button.
  • The module automatically omits empty JSON groups.
  • The module is intended to be used with DPL output, rather than being tied to any particular data source.

Template Data

Converts custom DPL output into copy-pastable Lua tables or JSON data.

Template parameters

This template has custom formatting.

ParameterDescriptionTypeStatus
DPL outputinfo

The raw output of a DPL query.

Stringrequired
Keyskeys

A ;;-separated list of keys to extract from the DPL output. Nested levels can be created with // and @@.

Stringoptional
Unquoted keysunquoted

A ;;-separated list of keys whose values should be output as raw Lua values instead of strings.

Stringoptional
Constant valuevalue

Sets the same value for every entry when no keys are specified.

Stringoptional
Sort keysortkey

The key used to sort the Lua output. Defaults to the page name. Use INPUT to preserve the original order.

Stringoptional
Subtable separatorsubtable

Splits values into subtables using the specified separator.

Stringoptional
Block formattingblock

Display the generated Lua table using block formatting.

Booleanoptional
Copy buttoncopy

Adds a copy button to the generated Lua table using the supplied header text.

Stringoptional
Clean Template:TtcleanTT

Automatically parses Template:Tt formatting from the DPL output.

Booleanoptional
JSON modejson

Set to 1 to output JSON instead of a Lua table.

Booleanoptional
JSON group 1group1

The name of the first JSON group.

Stringoptional
JSON group 1 datagroup1_info

The DPL output used to populate JSON group 1.

Stringoptional
JSON group 2group2

The name of the second JSON group.

Stringoptional
JSON group 2 datagroup2_info

The DPL output used to populate JSON group 2.

Stringoptional
JSON group 3group3

The name of the third JSON group.

Stringoptional
JSON group 3 datagroup3_info

The DPL output used to populate JSON group 3.

Stringoptional
JSON group 4group4

The name of the fourth JSON group.

Stringoptional
JSON group 4 datagroup4_info

The DPL output used to populate JSON group 4.

Stringoptional
JSON group 5group5

The name of the fifth JSON group.

Stringoptional
JSON group 5 datagroup5_info

The DPL output used to populate JSON group 5.

Stringoptional
JSON group 6group6

The name of the sixth JSON group.

Stringoptional
JSON group 6 datagroup6_info

The DPL output used to populate JSON group 6.

Stringoptional
JSON group 7group7

The name of the seventh JSON group.

Stringoptional
JSON group 7 datagroup7_info

The DPL output used to populate JSON group 7.

Stringoptional
JSON group 8group8

The name of the eighth JSON group.

Stringoptional
JSON group 8 datagroup8_info

The DPL output used to populate JSON group 8.

Stringoptional
JSON group 9group9

The name of the ninth JSON group.

Stringoptional
JSON group 9 datagroup9_info

The DPL output used to populate JSON group 9.

Stringoptional
JSON group 10group10

The name of the tenth JSON group.

Stringoptional
JSON group 10 datagroup10_info

The DPL output used to populate JSON group 10.

Stringoptional