Template:Viewsource

From Wikimedia Commons, the free media repository
Jump to: navigation, search
{{msgnw:{{{1}}}}}
Documentation icon Documentation[view] [edit] [history] [purge]

This documentation is transcluded from Template:Viewsource/doc.


This template can be used to transclude the source of another template onto a page.

Usage[edit]

{{viewsource|template name|(optional parameters)}}

Optional parameters:

  • nowrap=1
    Disable wrapping. By default, the template includes CSS style rules to make long lines in the source code wrap. Set this parameter to a non-empty value to disable it.
  • class=class names
    Include additional custom CSS classes. See MediaWiki:Common.css for available classes.
  • style=CSS
    Directly include additional custom CSS style rules. For example, to make the border red, you could use "style=border: 1px solid red;".

Example:

To display the source code of Template:Information, use {{viewsource|Information}}, which produces:

<noinclude>{{heavily used template}}</noinclude><div class="hproduct">
<table class="toccolours vevent mw-content-{{Dir|{{int:lang}}}}" style="width: 100%; direction: {{Dir|{{int:lang}}}};" cellpadding="4">

<tr style="vertical-align: top">
<td id="fileinfotpl_desc" class="fileinfo-paramfield">{{int:wm-license-information-description}}<span class="summary fn" style="display:none">{{PAGENAME}}</span></td>
<td class="description">
{{ #if: {{{description|{{{Description|}}} }}} | {{{description|{{{Description|}}} }}} | {{Description missing}} }}
</td>
</tr>

{{{other_fields_1|{{{Other_fields_1|{{{other fields 1|{{{Other fields 1|}}} }}} }}} }}}

<tr style="vertical-align: top">
<td id="fileinfotpl_date" class="fileinfo-paramfield">{{int:wm-license-information-date}}</td>
<td>{{ISOdate|{{{date|{{{Date|}}} }}} }}</td>
</tr>

<tr style="vertical-align: top">
<td id="fileinfotpl_src" class="fileinfo-paramfield">{{int:wm-license-information-source}}</td>
<td>{{ #if: {{{source|{{{Source|}}} }}} | {{Parse source|{{{source|{{{Source|}}} }}} }} | {{Source missing}} }}</td>
</tr>

<tr style="vertical-align: top">
<td id="fileinfotpl_aut" class="fileinfo-paramfield">{{int:wm-license-information-author}}</td>
<td>{{ #if: {{{author|{{{Author|}}} }}} | {{Information/author processing|author={{{author|{{{Author|}}} }}}}} | {{Author missing}} }}</td>
</tr>

{{#if:{{{permission|{{{Permission|}}} }}}{{{demo|<noinclude>1</noinclude>}}}|
<tr style="vertical-align: top">
<td id="fileinfotpl_perm" class="fileinfo-paramfield">{{int:wm-license-information-permission}}<br /><small>([[{{int:wm-license-information-permission-reusing-link}}|{{int:wm-license-information-permission-reusing-text}}]])</small></td>
<td>
{{{permission|{{{Permission|}}} }}}
</td>
</tr>
}}

{{#switch: {{{other_versions|{{{Other_versions|{{{other versions|{{{Other versions|}}} }}} }}} }}}{{{demo|<noinclude>1</noinclude>}}}
|   =
| - =
| none =
| #default = 
<tr style="vertical-align: top">
<td id="fileinfotpl_ver" class="fileinfo-paramfield">{{int:wm-license-information-other-versions}}</td>
<td>
{{{other_versions|{{{Other_versions|{{{other versions|{{{Other versions|}}} }}} }}} }}}
</td>
</tr>
}}

{{{other_fields|{{{Other_fields|{{{other fields|{{{Other fields|}}} }}} }}} }}}

</table>
</div>{{#switch:{{NAMESPACENUMBER}}|6|10=
{{#invoke:TemplatePar|check
|opt= 
description= Description=
date= Date=
source= Source=
author= Author=
permission= Permission=
other_versions= Other_versions= other versions= Other versions=
other_fields= Other_fields= other fields= Other fields=
other_fields_1= Other_fields_1= other fields 1= Other fields 1=
demo=
1=
|cat= Pages using Information template with incorrect parameter
|template= [[Template:Information]]
}}
{{#if:{{{1|}}}|<span style="color:red">Syntax error in [[Template:Information]]: “{{{1}}}”</span>[[Category:Pages using Information template with syntax errors]]}}
}}<noinclude>

{{documentation|Template:Information/doc}}

</noinclude>

Hints:

To transclude the source of non-template pages, include the namespace in the page name, e.g. {{viewsource|Help:Contents}}. To display the source of pages in the main (gallery) namespace, prefix the page name with a colon (":"), e.g. {{viewsource|:Main Page}}.

See also[edit]