Jump to content

Talk:Extended template syntax

Add topic
From Meta, a Wikimedia project coordination wiki
Latest comment: 18 years ago by 84.194.112.7 in topic meanwhile

An "if"/"switch"-like feature for conditional inclusion of wikitext based on the value of a parameter could also be useful (for example, determining the color-coding of a databox based on the value of a particular parameter—the language databox is color-coded based on the language family). I thought of a syntax for it, using multiple pipes, but then realized that that would cause problems for including table code. - Gwalla 02:08, 30 Jun 2004 (UTC)

if defined:

[edit]

This looks useful. It seems like there ought to be a simpler form to match the numerical parameters, i.e. {{{if defined:1|{{{1}}} }}}. How much time might there be until it becomes a feature? --Eequor 06:11, 15 Jul 2004 (UTC)

Hmm...you have a point. Maybe it should just insert the contents of the argument if a pipe isn't included, as in {{{if defined:1}}}? — Gwalla 17:40, Jul 23, 2004 (UTC)
That doesn't seem particularly useful. The construct ought to be able to insert any text, including text that doesn't contain the parameter. --Eequor 19:56, 23 Jul 2004 (UTC)
You misunderstand. That's why I said if a pipe isn't included. If the pipe is included, it'd behave like in the main proposal, which means it would insert whatever wikitext appears after the pipe (which may or may not include the parameter itself). In other words, {{{if defined:parameter}}} would be a sort of shorthand for {{{if defined:parameter|{{{parameter}}} }}}.
Wait, now that I think about it, I misunderstood what you were saying in the first place. I think. What do you mean by "a simpler form to match the numerical parameters"? {{{if defined:1|{{{1}}} }}} would just insert the contents of a parameter called "1" if it was defined. I guess I don't understand what you're getting at. — Gwalla 21:42, Jul 24, 2004 (UTC)

I miss 'else'. For example:

{{{if defined:author| ... is writen by {{{author}}} | unknown author }}}

or

{{{if defined:author| ... is writen by {{{author}}} }}}
{{{if undefined:author| author is unknown }}}

<user unknown> 20:49, 10 Aug 2004 (UTC) ;)


I support this proposal, and the else idea, that is "{{{if defined:author| ... is writen by {{{author}}} | unknown author }}} siroχo 14:54, 11 Aug 2004 (UTC)

Conditional sections would be very useful for me in Template:Infobox_Arcade_Game, as the alternative would be writing several templates (a screenshot is not available for every arcade game, and the designer is often unknown as well). It's also very useful when the infobox would need to get an extra field: otherwise all pages that use it would be broken until the new parameter has been added. --217.226.16.113 12:12, 5 Sep 2004 (UTC)

Conditional text

[edit]

Not sure I understand the "conditional text" proposal that was added. It isn't very clear. — Gwalla | On Wikipedia 03:46, Sep 12, 2004 (UTC)

The anon who posted it was trying to make the conditional robust. Now's the time to do it, too, while this is still a proposal. I've clarified the sub-proposal and added some examples that should help. All in all, I think it's a good modification to your excellent proposal. Benc 06:59, 13 Sep 2004 (UTC)
I understand what it's trying to do, but I still don't understand how it's supposed to work, really. I have a counterproposal that I'll add soon. — Gwalla | On Wikipedia 21:21, Sep 21, 2004 (UTC)
I also added the section about message truncation — an idea that I've been brewing for a while now. Please let me know if it needs clarification, too. Benc 07:26, 13 Sep 2004 (UTC)
I like the text manipulation idea, although I don't really get the rationale for length-based truncation here. But it's kind of tangential to the rest of the proposal, AIUI. It's more about a syntax for substitution text into an article, while the rest is about the code in templates. Maybe "extended template syntax" is too broad a title? — Gwalla | On Wikipedia 21:21, Sep 21, 2004 (UTC)

Default values

[edit]

I don't know if this would be instead of or as well as the more complex examples here, but what a lot of people have been asking for is a simple syntax for declaring default values. So if the parameter is not supplied, it doesn't just show up as weird wikicode. Something like

{{{parameter|default=Not supplied}}}

One thing that would need deciding on this is whether the default should be provided the first time the parameter is used (i.e. the above sets the default, but also displays the parameter), or as a seperate statement (the above would go at the top of the template and be invisible except in the source), or both (a variation on the syntax would enable or disable display of the parameter). The disadvantage of it being visible being that you have to find where in the template it first appears, which may be hidden among a load of other wikicode, making the whole thing get pretty ugly. - IMSoP 02:10, 26 Sep 2004 (UTC)

It would be nice to be able to store such things on a separate page. Wiki suffers from trying to make every page self-contained. Templates are an improvement, but the mindset still seems to value monolithic articles over modularity (consider how long the five-template limit has remained despite the reasons against it, or look at any infobox). Each page should have a separate layout template associated with it, to avoid cluttering the article with overwhelming tables; each template should be able to store its meta-information on a separate page, to avoid cluttering its content with preprocessing code. Meta-markup shouldn't be treated as identical to HTML-producing markup. --Eequor 04:25, 26 Sep 2004 (UTC)
Another problem: the template syntax is an attempt to cram some form of attribute markup into a language that was originally intended to eliminate attributes. Wiki syntax is entirely unsuitable for any set of loosely defined or non-unique parameters. Image markup only works because the ability to specify the height of an image was removed. The table markup gives up trying to replace HTML with wikicode. Are there any organized plans for reintroducing attributes in a consistent manner free of special cases? --Eequor 04:47, 26 Sep 2004 (UTC)
I think my {{if}} proposal addresses this. You'd use "undefined". — Gwalla | On Wikipedia 21:24, Sep 26, 2004 (UTC)

Being able to parse querystrings within the wiki language would be a huge boon to the future development and customization of wikis...

Wiki syntax should not become PHP

[edit]

The Wiki syntax has been defined for easy writing of formatted documents. Adding programming feature such as theese contitionnal statement would be awful:

  • It would make wiki syntax less readable which is against the Wiki principle
  • Complexifying the Wiki syntax improve the difficulty for the development of alternative interfaces to Wikipedia (paper print, bot development, plugins for other softwares...)
  • Conditionnal statements could be exploited by vandals to hide text to selected users. Eg. show bad text only to anonymous users.

Olivier Mengué 2004-10-06

I disagree. This syntax could make wiki syntax more readable for articles by pushing complexity out of the article code and into the template code. Right now, for example, the language infobox requires the editor to manually add the HTML color code, but with conditionals the template itself could select the infobox color based on the language family.
This proposal is only for conditionals based on template parameters, which only change when somebody edits the article to change them. It does not propose dynamic content. Nothing here would make alternative interfaces more difficult to create, or allow something like showing vandalism to anons. — Gwalla | On Wikipedia 00:12, Oct 9, 2004 (UTC)
I also heartily disagree. Using small conditional statements will not overcomplicate the templates. If anything, it will make it simpler because one does not have too keep multiple templates for each case. For example, if a parameter is not defined, then it will be simple to not include any markup associated with it, so you will not end up with empty markup. --Avochelm 07:23, 21 May 2005 (UTC)Reply

Preparing current templates

[edit]

Maybe we could convert current templates to a version that uses Extended template syntax; eg; the Extended template syntax version of Template:Holiday would be Template:X-Holiday

Template:Test would be Template:X-Test

This would only be until the software is updated for Extended template syntax

24.46.152.130 23:42, 20 Oct 2004 (UTC)

"nested" templates and templates as parameters

[edit]

A prototype implementation

[edit]

After only a few days of using MediaWiki, I realized that a nice handling of variable number of parameters are going to make templates a really powerful feature. I found this page here, and then decided to build this as prototype.

However, I did change the syntax a little to be more MediaWiki-like, with a touch of programming. My first prototype used natural language sequences such as __IF__(expression), but it look ugly. (Keep in mind that beauty is in the eye of the beholder, and this eye did not like it! Other eyes are free to like/dislike it.:) So I opted for a more {{{if}}} approach.

I have added a new page with a suggested syntax and a reference to the protype code.

-- brian

How does this happen?

[edit]

I think this is a good idea. The Probability distribution template is fine for continuous probability distributions but we need to take out a field or two for discrete probability distributions. My question is, what can I do to help make this actually happen? I don't have expertise in this field, only a need. Where do I go to vote? 69.143.60.69 17:23, 26 Mar 2005 (UTC)

I'm still waiting for it too. Adding a new parameter to a widely used template is a nightmare if you want to have articles look tidy. A lot of movie articles in my usual Wikipedia have a movie template. Some people want to add a line for the tag line (if any) but have better things to do thank update 500 articles with new information. "Ifdef" could be a big help in introducing new paramters. Thuresson 01:03, 3 Apr 2005

select/array template

[edit]
 Template:country_name
 {{select|key={{1}}|AU=Australia|BR=Brazil|NZ=New Zealand}}
I you are referring to the current software (by the way, this page is about possible extensions) {{{{{{key}}}}}} would be a call of a template with the name {{{{key}}}} without parameters. Why would this work? For something similar that works, see Help:Template_names,_variable_names_and_parameters_depending_on_a_variable_or_parameter#A_1D_array_contained_in_a_template.--Patrick 07:16, 21 July 2005 (UTC)Reply
Brilliant, All figured... thanks... basically I was lost and you pointed me in the right direction (and saved me from creating a million useless templates).
NevilleDNZ 10:48, 21 July 2005 (UTC)Reply

extended catalog pipetrick syntax

[edit]

I was looking at http://en.wikipedia.org/wiki/Eight-thousander, and it occured to me that a Category with extended "pipetrick" could be used to generate an index table, not just a catagory with 1 char index.

eg: by putting (maybe in a template) the following into Mount Everest: [[Category:Peak|Name=Mount Everest|8850|Height=8850||region=NP|First Ascent|[[May 29]], [[1953]]|First ascensionist=[[Edmund Hillary]] and [[Tenzing Norgay]] ]] . It could/would generate a table, instead of just a (1 char) alphabetical list. And by using a second field, then table could be sorted into ascending height. This would encourage the growth of consistent indexes.

And where two table are desired, eg ordered by date climbed, and also ordered by height, then a template could be used to generate both/two catagories. But have a different name (date & height), put this value after the first pipe.

Also the column titles can be derived, eg: Height=8850. would be a column.

This would reduce the hand editing to create indices, and also improve over all consistency.

And it fits in nicely with existing syntax. NevilleDNZ 13:19, 23 July 2005 (UTC)Reply

Vote?

[edit]

I think this is a swell idea! On the Wikipedia i've been trying to standardize some boxes, but its impossible to do so without breaking the meta-templating rule, and thus increasing server stress. I've been looking for something just like this to help that; show a box if a parameter is defined, dont if it isnt. Certainly, i am against dynamizing much more of wiki, but a small trick like this would help greatly in standardizing Wiki content, and helping authors who know little of coding itself, but want to contribute nonetheless. So whens the vote? --The Minister of War 10:21, 29 September 2005 (UTC)Reply

Observation

[edit]

The {{{subst: }}} regular expression sytnax suggested is not only the easiest one of these suggestions to code into the wiki, but it also contains most of the fucntionality of all the rest. w:User:Shimmin

I'm a self described lurker on the main Wikimedia site, but I've been fiddling with a Template for a non-Wikipedia related Wiki-using community site... (what a long description). I was wondering if the "if defined:" addition actually worked or if there is another way of making a Template parameter optional. If anyone knows of a way, I'd really appreciate a response, (drop a comment here if you want). ~ Interested newbie

meanwhile

[edit]

use en:Category:If_Templates--84.194.112.7 20:40, 19 January 2006 (UTC)Reply