词条 | Module:Dump/doc |
释义 |
This module can dump a table by displaying its contents as text. It can also display formatted html text. That may help develop other modules. An alternative is to use Dump of a Wikidata entityWhen working with Wikidata, it can be useful to examine a table representing an entity. For example, Southern African Large Telescope is Q833639. That entity can be viewed as a Lua table by previewing:
To do that, edit your sandbox and replace its contents with the above line, then click Show preview. Dump shows this example. If wanted, the width of each indented column can be set, for example to 2 spaces:
A property such as {{Q|P2386}} can also be displayed:
Dump of a table for another moduleIf there is a problem debugging a module, it can be helpful to use a sandbox copy of the module to display the contents of a table to confirm that it contains expected data. The following shows how a module can dump a table. With the above code in Module:Example, the result could be displayed by previewing:
The module contains a complex table for testing. The table can be displayed by previewing:
Dump of a formatted html stringA module can use mw.html to generate html. For testing, it may be useful to display the formatted result. The following shows how a module can create and dump html text. With the above code in Module:Example, the result could be displayed by previewing:
The result is: <table class="wikitable"> <caption>Table demonstration</caption> <tr> <th>Month</th> <th>Amount</th> </tr> <tr> <td>January</td> <td>$100<br>loss</td> </tr> <tr> <td>February</td> <td>$200</td> </tr></table> The In that case, the result could be displayed by previewing the following (the
Dumping a navboxPreviewing the following examples in a sandbox may be useful to examine the results of a template, such as {{tl|navbox}}, that generates html. {{#invoke:dump|dumphtml|1= {{navbox/sandbox |group1 = Group1 |list1 = List1 |group2 = Group2 |list2 = List2 |group3 = Group3 |list3 = List3 }}}} The dumphtml procedure only works reliably with valid html. In the following example, extra text ( {{#invoke:dump|dumphtml|1=<div> {{navbox/sandbox|subgroup |group1 = Group1 |list1 = List1 |group2 = Group2 |list2 = List2 |group3 = Group3 |list3 = List3 }}}} Global table _GIn Lua,
If wanted, the width of each indented column can be set, for example to 2 spaces:
|
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。