I'm looking for a way that a user may specify a table - i.e. by specifying it in MediaWiki syntax - to a template. The template should then put this table in the context of some larger output provided by the template.
A simple example. Is there a way a user could specify something like this:
{{MyTemplate
|FooBar
|{| class="wikitable"
| Something
|-
| Useful
|}
}}
and then the template outputs somewhere the specified data
and the table?FooBar
If this doesn't work, is there some alternative way of doing this? i.e. by specifying some arbitrary (!) CSV data and outputting it in a formatted way?
The reason it doesn't work is that the pipes in the table are seen by the template as parameter delimiters. The {{!}} magic word exists as a workaround to this, so your example could be done like this:
{{MyTemplate
|FooBar
|{{{!}} class="wikitable"
{{!}} Something
{{!}}-
{{!}} Useful
{{!}}}
}}
This does make it rather less readable though!
As for rendering CSV data as a table, the TableData extension may do what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With