Template:Tl/doc
Jump to navigation
Jump to search
This template returns an exemplary use of a template while linking to the template description page, if the template exists. It can also handle parser functions.
Usage
All parameters are optional.
- Templates:
{{{{#rmatch: <template name> |^#(\s*(\w+?)\s*)(:(.*)$|$)|#$1:$4| <template name> }}{{#dplreplace:|/₪/||}}}}
- Parser functions:
{{{{#rmatch: #<parser function name>: |^#(\s*(\w+?)\s*)(:(.*)$|$)|#$1:$4| #<parser function name>: }}{{#dplreplace:|/₪/||}}}}
- First unnamed parameter
Template (without the Template:Code prefix) or parser function name. The colon at the end of the parser function's name may be omitted, or it may immediately be followed by the parser function's first parameter.
- Unnamed parameters
Other parameters, ad infinitum.
- nl
Set this parameter to suppress the link to the template/parser function documentation. Links to parser function documentation are stored in Template:Tl/parser function links.
- code
Set this parameter to wrap the output in <code> tags.
Notes
- To display named parameters or to otherwise include equals signs, use {{{{#rmatch:=|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|=}}{{#dplreplace:|/₪/||}}}}. Unescaped equals signs will cause the entire parameter to be hidden.
Examples
Code | Result | |
---|---|---|
{{tl|stub}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|stub}}{{#dplreplace:|/₪/ | }}}} |
{{tl|stub|1}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|stub}}{{#dplreplace:|/₪/ | }}}} |
{{tl|stub|1|2}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|stub}}{{#dplreplace:|/₪/ | }}}} |
{{tl|nl=y|stub|1|2}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#$1:$4|stub}}{{#dplreplace:|/₪/ | }}}} |
{{tl|code=y|stub|1|2}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|stub}}{{#dplreplace:|/₪/ |
}}}} |
{{tl|nl=y|code=y|stub|1|2}} |
{{{{#rmatch:stub|^#(\s*(\w+?)\s*)(:(.*)$|$)|#$1:$4|stub}}{{#dplreplace:|/₪/ |
}}}} |
{{tl|#if}} |
{{{{#rmatch:#if|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|#if}}{{#dplreplace:|/₪/ | }}}} |
{{tl|#if:}} |
{{{{#rmatch:#if:|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|#if:}}{{#dplreplace:|/₪/ | }}}} |
{{tl|#if:condition}} |
{{{{#rmatch:#if:condition|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|#if:condition}}{{#dplreplace:|/₪/ | }}}} |
{{tl|#if:condition|then|else}} |
{{{{#rmatch:#if:condition|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|#if:condition}}{{#dplreplace:|/₪/ | }}}} |
{{tl|#listmap:|list{{=}}1, 2, 3}} |
{{{{#rmatch:#listmap:|^#(\s*(\w+?)\s*)(:(.*)$|$)|#[[[:Template:Tl/parser function links]]##$2 $1]:$4|#listmap:}}{{#dplreplace:|/₪/ | }}}} |