-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic generation of infobox structure #121
Comments
You can use the So, your code could be rewritten as: {{#tag: infobox |
<panel>
<section>
<label>First section</label>
...
</section>
{{#if: {{{has section 2|}}} | <!-- Conditionally add a second section to the panel. -->
<section>
<label>Second section</label>
...
</section>
}}
</panel>
}} This also means that you can use other wikitext syntax like, for example, #invoke and templates in areas where they normally would be ignored by the extension. For example, you could abstract your section logic into another template, say <section>
<label>{{{number|1}}}th section</label>
...
</section> ... and then just call that template in your main function: {{#tag: infobox |
<panel>
{{Infobox/1|number = 1}}
{{#if: {{{has section 2|}}} |
{{Infobox/1|number = 2}}
}}
{{#if: {{{has section 3|}}} |
{{Infobox/1|number = 3}}
}}
{{#if: {{{has section 4|}}} |
{{Infobox/1|number = 4}}
}}
</panel>
}} Note this may have some side-effects on areas where you'd normally use wikitext, e.g. in |
@Williek11 Thanks for the tip. I've tried this out, but unfortunately it seems I would need to escape a daunting number of special characters. For example:
It seems doable but... It's all a bit much. I wonder if certain tags, like <infobox>
<panel>
<section if="hasSection1">
...
</section>
<section if="hasSection2">
...
</section>
</panel>
</infobox> (And, ideally, if a I'm working on a bunch of other things on my wiki already (like trying to make |
One issue, though, is that you can't actually abstract logic into another template easily with wikitext alone, mainly because arguments wouldn't be processed and that causes a mess. It could theoretically be done by creating a module that passes the parent's arguments to the child, or just manually aswell, but alas, that's outside the scope of this issue. Onto the actual issue, I feel this would be a nice addition to the extension as my solution is, admittedly, a bit cheesy. Maybe it would be more convenient to use tag syntax with wikitext so we can use logic on the template? Or simply the ability to use wikitext in an attribute (although it would be fairly different from the rest of the syntax in the extension)? For example: <infobox>
<panel>
<!-- no. 1 -->
<section>
<show>{{#ifeq: {{{class|}}} | mage | y}}</show>
...
</section>
<!-- or no. 2 -->
<section if="{{#ifeq: {{{class|}}} | mage | y}}">
...
</section>
</panel>
</infobox> |
Is there a way to generate the infobox structure dynamically? For example, using Wikitext parser functions to generate the XML that specifies the infobox structure? Or maybe a Lua API of sorts?
Pseudo-code for example purposes; I know this doesn't work:
The reason I wish to have something like this:
I'm building an infobox for creatures in a video game. The "statistics" part of the infobox may contain multiple tabs per difficulty setting of the game, if the creature's stats change depending on difficulty. There's four difficulty options one can choose from, and it's annoying when the infobox lists four tabs with identical contents for some trivial creatures that always have the same stats.
The text was updated successfully, but these errors were encountered: