Topic on Help talk:TemplateData

What's the convention to set a default value?

4
Summary by Cyberkagami

Template:If then show works great, thanks!

Cyberkagami (talkcontribs)

Since the template data does not have any functional feature to actually set it, I wonder what's the convention to set one.

I was using {{{param|defaultvalue}}} syntax, but this doesn't work well if the param is marked as "Suggested" because then the visual editor defines it as an empty string and thus shadows the default value.

{{#if:{{{param|}}}|{{{param}}}|defaultvalue}} does work, but is this really a convention? What do others do?

FeRDNYC (talkcontribs)

On Wikipedia there's Template:If then show, which slightly simplifies the syntax for doing exactly the same thing as your {{#if:...}} version, e.g.:


{{If then show|{{{param|}}}|defaultvalue}}

Jonesey95 (talkcontribs)

Search this Help page for "default" and "autovalue". One of those may be what you want.

Tacsipacsi (talkcontribs)

@Cyberkagami: Yes, {{#if:{{{param|}}}|{{{param}}}|defaultvalue}} is a convention. It not only helps with VisualEditor and TemplateData, but also makes possible to create copy-pastable “skeletons” in old-fashioned template documentation, like this one:

{{Infobox foo
|param = 
|bar   = 
|baz   = 
}}

which would also be broken by the {{{param|defaultvalue}}} syntax if unused parameters are not entirely removed.