From Wikimedia Commons, the free media repository
Jump to: navigation, search

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


{{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;".


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

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

<!-- Description -->
<tr style="vertical-align: top">
<td {{ #if: {{{description|{{{Description|}}} }}} | id="fileinfotpl_desc" }} class="fileinfo-paramfield" lang="{{int:lang}}">{{int:wm-license-information-description}}<span class="summary fn" style="display:none">{{PAGENAME}}</span><!-- required for hCalendar and hProduct microformat; though hMedia would be more appropriate --></td>
<td class="description">
{{ #if: {{{description|{{{Description|}}} }}} | {{{description|{{{Description|}}} }}} | {{Description missing}} }}

<!-- Other fields 1 -->
{{{other_fields_1|{{{Other_fields_1|{{{other fields 1|{{{Other fields 1|}}} }}} }}} }}}

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

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

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

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

<!-- Other versions -->
{{#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" lang="{{int:lang}}">{{int:wm-license-information-other-versions}}</td>
{{{other_versions|{{{Other_versions|{{{other versions|{{{Other versions|}}} }}} }}} }}}

<!-- Other fields -->
{{{other_fields|{{{Other_fields|{{{other fields|{{{Other fields|}}} }}} }}} }}}

</div>{{Infobox template tag}}{{#ifexpr:{{Years since|1={{ISOyear| {{{date|{{{Date|}}} }}} }}|error=0 }}>200 | {{Works created more than 200 years ago}} }}<!--
Parameter maintenance
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=
|cat= Pages using Information template with incorrect parameter
|errNS= 6 10
|template= [[Template:Information]]




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]