Friday, June 18, 2010

Variables on templates

Pregunta:

Hi, I was studying the Wikipedia Templates and I have see somes codes like this:
style="{{{bodystyle|}}};{{{style|}}}">...
But "bodystyle" isn't defined anywhere and it isn't invoked but has a value in the page result. Exists some meaning to define this values? Thanks.

Respuesta 1:

Yes. It is set on call.

Eg. if you have tamplate foo containing:
{{{1}}}
You could call it as:
{{foo|Hello World!|style=color: blue|bodystyle=background-color: red}}
And the result will be:
Hello World!


Respuesta 2:

In this case, both "bodystyle" and "style" are parameters that are
passed to the template by whatever is instantiating it (e.g. another
template or an instance of the template living on a page somewhere). For
example:
{{some template | bodystyle = color:black; | style = font-weight:bold; }}


Hope that makes sense.

Ryan Kaldari

No comments:

Post a Comment