Gentoo Wiki:Template Migrations/Code, File, Kernel

From Gentoo Wiki
Jump to: navigation, search

We are deprecating the currently widely-used {{Code}}, {{File}}, and {{Kernel}} templates in favor of {{CodeBox}}, {{FileBox}}, and {{KernelBox}} for these reasons:

  • The new names explicitly tell the author that they produce block-level elements with a border (=box) and are explicitly not inline templates.
  • The 'API' was changed to only have the box contents as anonymous required parameter. All other parameters are named, making the template more flexible.
  • Syntax highlighting support was properly implemented.

Some of these changes require manual verification of the rendered result, as well as annotating with a source language, and we hope you can assist us with this.

What do I need to do?

Basically, for every Code, File, or Kernel template you find:

  • Add "Box" to the template name.
  • Convert the title into a named argument (if there is one).
  • Convert the file name into a named argument (if there is one).
  • Set a source language.

Examples

File

Convert instances of the {{File}} template, currently found in these articles, as follows:

Old template:

{{File|/etc/default/grub|Framebuffer related settings|<pre>
# Set resolution and color depth
GRUB_GFXMODE=1366x768x32

# Keep resolution when loading the kernel
GRUB_GFXPAYLOAD_LINUX=keep
</pre>}}

New template:

{{FileBox|filename=/etc/default/grub|title=Framebuffer related settings|lang=bash|1=
# Set resolution and color depth
GRUB_GFXMODE=1366x768x32

# Keep resolution when loading the kernel
GRUB_GFXPAYLOAD_LINUX=keep
}}

Using <pre> is no longer needed, the template takes care of preserving the whitespace on its own. Should you need to escape contents, use 1= or <nowiki>. (Note that keeping the <pre> tag will break syntax highlighting.)

Code

Convert instances of the {{Code}} template, currently found in these articles, as follows:

Old template:

{{Code||<pre>
# Set resolution and color depth
GRUB_GFXMODE=1366x768x32

# Keep resolution when loading the kernel
GRUB_GFXPAYLOAD_LINUX=keep
</pre>}}

New template:

{{CodeBox|lang=bash|1=
# Set resolution and color depth
GRUB_GFXMODE=1366x768x32

# Keep resolution when loading the kernel
GRUB_GFXPAYLOAD_LINUX=keep
}}

You can discard the empty title parameter as there is no title, just add the source language, and use 1= instead of <pre>.

Kernel

The {{Kernel}} template, currently found in these articles, works similarly to the Code template, just without syntax highlighting support. As such, <pre> tags can still be used. As of 23 January 2017, all instances of this template have been converted (but you can check the link to see if that's still true).

Questions?

Mini FAQ

What do I do with | characters?
Replace them with {{!}}

As always, if you have any questions or find any problems stop by the #gentoo-wiki IRC channel, or email us (at wiki@gentoo.org). If not, thanks for your help making the Wiki even better. :)