Template:File: Difference between revisions

From NixOS Wiki
imported>Samueldr
No edit summary
Sdht0 (talk | contribs)
Remove extra line break
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<noinclude>{{Template}}{{DISPLAYTITLE:Template:file}}
<noinclude>{{Template}}{{DISPLAYTITLE:Template:file}}
The contents of a file.
 
== About ==
Used to display contents of a file.
{{META Pipe Character}}
{{META Pipe Character}}


== Usage ==
== Usage ==


  <nowiki>{{File|filename|language|contents}}</nowiki>
  <nowiki>{{file|filename|language|contents}}</nowiki>


See documentation about <code>&lt;syntaxhighlight></code> for supported languages.
See documentation about <code>&lt;syntaxhighlight></code> for supported languages.


== Example ==
  <nowiki>{{file|main.c|c|
 
<nowiki>{{File|main.c|c|
#include <stdio.h>
#include <stdio.h>


Line 20: Line 20:
}}</nowiki>
}}</nowiki>


<hr />
== Example ==
{{File|main.c|c|
{{file|main.c|c|
#include <stdio.h>
#include <stdio.h>


Line 29: Line 29:
}
}
}}
}}
<hr />


</noinclude><includeonly><div
</noinclude><includeonly><div
   style="
   style="
     width: 0;
     width: 1.2em;
     height: 0;
     height: 0;
     position: relative;
     position: relative;
     top: 1.9em;
     top: 0.8em;
     left: 1em;
     left: 0.8em;
   "
   "
>{{{icon|[[Image:Breeze-text-x-plain.png]]}}}</div>{{#tag:pre|{{{filename|{{{1|{{META Error}}}}}}}}
>{{{icon|[[Image:Breeze-text-x-plain.png|link=]]}}}</div>{{#tag:pre|{{{filename|{{{1|{{META Error}}}}}}}}
|style=margin-bottom: 0; border-bottom:none; padding-bottom:0.8em; padding-left:2.7em;
|style=margin-bottom: 0; border-bottom:none; padding-bottom:1em; padding-left:2.7em; margin-top: 0;
}}{{#tag:syntaxhighlight|{{{contents|{{{3|{{META Error}}}}}}}}
}}{{#tag:syntaxhighlight|{{{contents|{{{3|{{META Error}}}}}}}}
|lang={{{lang|{{{2| }}}}}}
|lang={{{lang|{{{2| }}}}}}
|style=margin-top: -1em;}}
|style=margin-top: -1em;}}</includeonly>
</includeonly>

Latest revision as of 12:00, 8 April 2024

This page is a template. It should be used as part of other articles. For more information, see Help:Template.

Please do not experiment with this template; you could ruin all pages using this template. If you want to edit this template, copy the text to Template:Sandbox, edit and test it there, and copy it back when it works.

Feel free to discuss this template in the talk page.

If you wanted to create a new page instead, use the search box to search for the title of the new page you want to create and follow the link Create the page "XYZ" on this wiki! in the results page. An alternative is to create a dangling link to the new page from an existing page. A final option is to directly visit the expected URL of the page.

About

Used to display contents of a file.

Special note

The pipe character cannot be used as is within the template, as it is a special characters for templates.

It can be included using the magic word {{!}}.

Alternatively, it is possible to instead surround the contents in <nowiki> tags.

Usage

{{file|filename|language|contents}}

See documentation about <syntaxhighlight> for supported languages.

 {{file|main.c|c|
#include <stdio.h>

main( )
{
        printf("hello, world\n");
}
}}

Example

main.c
#include <stdio.h>

main( )
{
        printf("hello, world\n");
}