Difference between revisions of "Help:Templates:ru"

From Valve Developer Community
Jump to: navigation, search
m
m (Adjustment in response to a change to Template:distinguish.)
 
Line 58: Line 58:
 
Result: {{tip|Do not carve without vertex editing afterward.}}
 
Result: {{tip|Do not carve without vertex editing afterward.}}
  
If you want to add more than one unnamed parameter, simply change the number. Here's the (condensed) code for [[Template:Distinguish]]:
+
If you want to add more than one unnamed parameter, simply change the number. Here's the old (condensed) code for [[Template:Distinguish]]:
 
<pre>:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]|&nbsp;or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''</pre>
 
<pre>:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]|&nbsp;or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''</pre>
 
This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: <code>{{{1}}}</code>, <code>{{{2}}}</code>, <code>{{{3}}}</code>, and <code>{{{4}}}</code>.
 
This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: <code>{{{1}}}</code>, <code>{{{2}}}</code>, <code>{{{3}}}</code>, and <code>{{{4}}}</code>.
Line 204: Line 204:
  
 
Example from [[Follow Freeman]]:
 
Example from [[Follow Freeman]]:
<pre>{{distinguish:ru|"Follow Freeman!"}}</pre>
+
<pre>{{distinguish:ru|"Follow Freeman!"|desc1=The HL2 chapter}}</pre>
Result: {{distinguish:ru|"Follow Freeman!"}}
+
Result: {{distinguish:ru|"Follow Freeman!"|desc1=The HL2 chapter}}
  
 
===ent===
 
===ent===

Latest revision as of 13:18, 9 October 2021

English Русский
Help:Editing:ru

Шаблоны позволяют выполнять действия намного быстрее и/или проще. Шаблоны очень часто используются на страницах, поэтому лучше узнать о них. Когда вики видит на странице распознанный ею шаблон, она автоматически заменяет его другим. Что там появится, зависит от пользователей.

Как использовать шаблон

Прежде чем шаблон может быть добавлен куда-либо, сначала его содержимое должно быть определено на его собственной странице. Страницы шаблонов должны начинаться с префикса Template:.

Шаблоны имеют некоторые ограниченные возможности программирования, что даёт им много возможностей. Подробнее о них мы поговорим позже.

Чтобы добавить шаблон на страницу (это называется транскрипция), просто введите {{, имя шаблона, а затем }}. Если вы хотите добавить какие-либо параметры, поместите | между именем шаблона и }} и определите параметры там. Все параметры, которые вы определите, должны быть разделены ещё одним символом |.

Note.png Примечание: Любая страница может быть исключена другой страницей. Ниже приведено исключение главной страницы:



Примеры

Вот шаблон, в котором мы не определяем никаких параметров, вы просто вставляете его прямо в шаблон.

{{restart:ru}}

Результат: Для вступления изменений в силу требуется перезапуск.

Если вы посетите страницу этого шаблона, то увидите, что в нём всего пять слов.


Шаблон ent - это шаблон, который может принимать до двух безымянных параметров.

{{ent|sv_cheats|1}}

Результат: sv_cheats 1

Безымянные параметры должны быть определены в определённом порядке.

Substitution (for advanced users)

Instead of transcluding a template, one can choose to substitute it. Substitution will replace a template with the contents of the template directly onto the page. To substitute a template, transclude it like you normally would, then add subst: between {{ and the template's name. After that, click the save button and the wikitext will automatically be added. Do not substitute carelessly, because the substituted wikitext will not be updated when the template is. See Wikipedia:Help:Substitution for more information.

{{subst:delete|This is a bad page.}}

When the page is saved, that text will be replaced with this:

{{Delete-meta|{{#if: This is a bad page. | This is a bad page. }} }}[[Category:Candidates for speedy deletion]]

Note the automatic forwarding of parameters. When substituting, the page should not appear any differently than it would if transcluded. The only difference is in the page code.

Making templates

Making a template like Template:Restart is rather easy - just type the text you want, and save it. What about ones with parameters?

Tip.png Tip: When making templates, you may want to space out your code to make it easier to read, but watch out for unintentional whitespace. HTML comments (<!-- -->) can also be useful.

Unnamed parameters

To add an unnamed parameter, simply put {{{1}}} where you want it to be.

Here's part of the code for Template:Tip:

Tip:{{{1}}}

If you've seen this template before you know that it has its own special look, but this is all we will look at for now. All the user has to do when transcluding this is enter the text they want:

{{tip|Do not carve without vertex editing afterward.}}

Result:

Tip.png Tip: Do not carve without vertex editing afterward.

If you want to add more than one unnamed parameter, simply change the number. Here's the old (condensed) code for Template:Distinguish:

:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]| or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''

This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: {{{1}}}, {{{2}}}, {{{3}}}, and {{{4}}}.

All the user has to do when transcluding is this:

{{distinguish|Combine|Civil Protection|Overwatch}}

Result:

Not to be confused with Combine, Civil Protection or Overwatch.

Named parameters

Usually you would want to have named parameters affect anything only if they are defined when being transcluded. We'll talk about conditions later. For now, let's look at Template:IO, which has many named parameters. In this template, {{{param}}} marks a place to add wikitext that's defined by |param=texthere when transcluding.

With named parameter:

{{IO|SetString|Updates the string.|param=string}}

Result:

SetString <string>
Updates the string.


Without named parameter:

{{IO|SetString|Updates the string.}}

Result:

SetString
Updates the string.

Default value

To make a parameter have a value by default, add a | to the right of the parameter name, and then define the value. Named and unnamed parameters can use this.

{{{1|3000}}}

This would make the value for 1 3000.

{{{value|}}}

This returns nothing. Without the |, it would literally return "{{{value}}}" as text, if it hasn't already been defined at some other point.

Parser Functions

#if: checks if a string or parameter has anything inside it.

{{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }}

Result: Sleep mode activated... (The parameter {{{target|}}} returns null because you (probably) are not viewing this page through a transclusion, so it's never had a chance to be defined.)

{{#if: Something is there! | Target aqcuired | Sleep mode activated... }}

Result: Target aqcuired


#ifeq: checks for equality between two strings. It can be used with parameters as well.

{{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}

Result: Go away!

{{#ifeq: friend | friend | Friend... | Go away! }}

Result: Friend...


#expr: solves math problems.

{{#expr: 2 + 2}}

Result: 4

See m:Help:Calculation for all it's abilities.


#ifexpr: tells if a math expression is correct.

{{#ifexpr: 6 + 3 = 9 | Right | Wrong }}

Result: Right

{{#ifexpr: 6 + 3 = 23 | Right | Wrong }}

Result: Wrong

Documentation

Please give a description of what your template is, and maybe examples. To keep this describing text from appearing on pages, there are 3 different HTML tags you can use.

noinclude keeps wikitext inside it from appearing on the destination page, while keeping it on the source page.

onlyinclude makes only wikitext inside it appear on destination pages. Text not inside these will still appear on the template's page.

includeonly wikitext inside this will not appear on the template page. It has no effect on the destination page however.

They can sound very confusing at first. If you're confused on how to use them, check the source code for a template, because almost all use them for one purpose or another.

Templates not updating

If you've recently edited a template and the changes are not applying on pages it's been transcluded to, add ?action=purge at the end of the URL for those pages. This will tell the server to update the page's HTML immediately. You can achieve the same effect by editing a page and saving it without making any changes.

Template shortcuts

Some templates may have template shortcuts, which are redirects that are abbreviated or otherwise different forms of their target templates. Template shortcuts can be transcluded just like their target templates.

Useful templates

All templates in green text are that color so that they stand out against the greyscale tones of most pages. Most templates with that color also automatically add pages they are transcluded on into Category:TODO.

Per-game templates

All games have templates that show their associated icon. (e.g. Half-Life 2) See Category:Game icons for the full list. Template:Game link is a template that automatically links to a game's page and displays its icon next to it. (e.g. Half-Life 2 Half-Life 2 )

The {{since}} template can be used to quickly note features that were added in a game and are available in all Source games afterwards (e.g. (in all games since Portal 2)) The {{only}} template indicates features that are exclusive to a specific game (e.g. (only in Counter-Strike: Global Offensive)).

The {{also}} template notes that earlier game also has a feature, usually backported from newer engine branches. These should be used with in conjunction with another game notice template (e.g. (only in Left 4 Dead) (also in Garry's Mod) or (in all games since Alien Swarm) (also in Garry's Mod)).

The {{removed}} template indicates that a feature was removed in a game and all later engine branches (e.g. (removed since Left 4 Dead)).

=

Template:= is a template that only returns an equal sign. The character is sometimes needed because multiple wiki features make use of it. An equal sign generated through this will never be counted as formatting.

bug

Template:Bug notifies readers of a bug.

{{bug|The amount is double what it should be. Be careful!}}

Result:

Bug.png Bug: The amount is double what it should be. Be careful!

clarify

Template:Clarify marks things that should be clarified.

PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}

Result: PAS is a kind of bounding-box for Player or NPC AI sound detection.[Clarify]

cleanup

Template:Cleanup marks a page that needs to be fixed up, preferably by someone knowledgeable. The text message is optional. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else.

{{cleanup|The last section needs to be clarified.}}

Result:

clr

Template:Clr clears the vertical space to the left or right of something. This is commonly used for making headlines not get moved around by images.

Skull and crossbones.png

This text should appear next to the image. If you put {{clr}} right after this,

this bit of text here will get moved down.


Skull and crossbones.png

This text should appear next to the image. If you put {{clr}} right after this,

this bit of text here will get moved down.

confirm

Template:Confirm marks something that needs to be confirmed. It's green color is meant to stand out.

{{confirm|Always goes to the left.}}

Result:

Confirm:Always goes to the left.
Always goes to the left.{{confirm}}

Result: Always goes to the left.[confirm]

delete

Template:Delete marks a page that should be deleted. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else. When putting this on a page, you should also list the reason on that page's talk page, for any future readers that may want to know the purpose of the deletion.

{{delete|This is not a real thing.}}

Result:

distinguish

Template:Distinguish:ru lets you notify users about pages that share similar names or may be confused for something else.

Example from Follow Freeman:

{{distinguish:ru|"Follow Freeman!"|desc1=The HL2 chapter}}

Result:

Не путать с "Follow Freeman!" (The HL2 chapter).

ent

Template:Ent is a really small template for making text that's both code and a link.

{{ent|noclip}}

Result: noclip

ExpandBox

Template:ExpandBox:ru allows you to hide stuff inside a box that can be shrunk down so that it doesn't make pages as long.

{{ExpandBox:ru|{{:KV BaseEntity}}}}

Result:



how

Template:How:ru asks the question how?

Players can get past these.{{how}}

Result: Players can get past these.[How?]

idea

Template:Idea:ru is a nifty way to suggest ideas.

{{idea:ru|Reward players for being clever and creative, instead of forcing things to be only one way.}}

Result: Template:Idea:ru

merge

Template:Merge is a notice that notifies editors that it's been suggested for two or more pages to be combined into one. All merges should be discussed before being done.

{{merge|HDR}}

Result:

messagebox

Template:Messagebox:ru provides a standard message box. This template is used by many notice templates, such as merge and cleanup.

{{messagebox:ru|text=Remember to follow wiki etiquette.}}

Result:

morescreenshots

Template:Morescreenshots:ru marks pages that should have more images on them. It allows for an optional text message to clarify what needs images.

{{morescreenshots:ru|$envmapcontrast, $envmapsaturation}}

Result:

note

Template:Note:ru is for making notes stand out more.

Bug.png Ошибка: Appears to not accept HTML tags inside it...?
{{note:ru|This will spawn at the map origin if you do not specify the position.}}

Result:

Note.png Примечание: This will spawn at the map origin if you do not specify the position.

obsolete

Template:Obsolete:ru marks things that should no longer be used. Accepts three parameters, entity, tool, and shader.

{{obsolete:ru|entity=1}}

Result:

otherlang2

Template:Otherlang2 is used for linking to versions of pages in other languages. For an example of its use, see the Main Page.

shortcut

Template:Shortcut:ru displays a small box noting (abbreviated) redirects to a page.

{{shortcut:ru|VDC:AL}}

Result: Template:Shortcut:ru

spammer

Template:Spammer marks users that should be banned for spamming.

Bug.png Ошибка: This template's formatting may look weird sometimes. It's intended to be the only thing on a page.
{{spammer}}

Result:

Spammer.jpg
Note.png Примечание: This user is a spammer, vandal or other problem poster and should be considered for a ban

split-apart

Template:Split-apart:ru marks pages that should be split into multiple pages. All splits should be discussed before being done.

{{split-apart:ru}}

Result:


stub

Template:Stub:ru marks pages that are very small. See Help:Stubs for info on using.

{{stub:ru}}

Result:

tip

Template:Tip:ru marks text as a tip to readers.

{{tip:ru|This is a much less tricky process when using the vertex edit tool as well.}}

Result:

Tip.png Совет: This is a much less tricky process when using the vertex edit tool as well.

toc-right

Template:toc-right:ru shifts the table of contents over to the right side of a page. For an example, see Half-Life 2 map reference.

todo

Template:Todo:ru marks things that need to be done. It's green color is meant to stand out.

{{todo:ru|Find where this is in the game files.}}

Result: To do: Find where this is in the game files.

unsigned

Template:Unsigned:ru is for talk pages. It should be added at the ends of unsigned comments.

{{unsigned:ru|JeffLane}}

Result: Template:Unsigned:ru

update

Template:Update:ru marks outdated pages.

{{update:ru}}

Result:

warning

Template:Warning:ru marks things that readers should take caution of when doing something.

{{warning:ru|This tool has been known to corrupt files. Try an alternative listed below.}}

Result:

Warning.png Предупреждение: This tool has been known to corrupt files. Try an alternative listed below.

why

Template:Why asks the question why?

This shader has been deprecated.{{why}}

Result: This shader has been deprecated.[Why?]

wip

Template:Wip:ru marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.

{{WIP:ru|~~~}}

Result:

Magic words

Magic words are special character strings that are kind of like templates. To apply one, simply type it on the page.

__TOC__

Forces the table of contents to be placed at this spot.

__FORCETOC__

Forces the table of contents to be placed at its normal spot. (Only useful on pages that don't have enough sections to automatically display a TOC.)

__NOTOC__

Hides the table of contents.

__HIDDENCAT__

Marks a category as hidden. To make the website show hidden categories for you, check the Show hidden categories box in Special:Preferences.

{{DISPLAYTITLE:title}}

Changes the title of a page at the top bar only.

See Also