الگو:Sp

از ویکی‌پدیا، دانشنامهٔ آزاد
پرش به ناوبری پرش به جستجو
توضیحات الگو[نمایش] [ویرایش] [تاریخچه] [پاکسازی]

Usage[ویرایش]

{{sp}} will insert a single, ordinary space character.

Anywhere you need a regular space[ویرایش]

You can use {{sp}} anywhere you need a regular, breaking space. If you need a non-breaking space or multiple spaces in a row, use {{space}} (or the shorter to type {{s}}).

Inserting a space inside a parser function[ویرایش]

Sometimes when using parser functions, you need to insert a space at the beginning or end of an optional message. {{sp}} can be used for that purpose. In the following examples, look closely at the spacing between words and punctuation to see the subtle differences.

Example
I like green{{#if:{{{blue|}}}|and blue}}.

The above example works fine if 'blue' does not have a value ('I like green.').

However, if 'blue' is set to true (|blue=true), then the message is incorrectly run together ('I like greenand blue.').

I like green {{#if:{{{blue|}}}|and blue}}.

Adding the space between 'green' and '{{#if' avoids running the 'green and' together, but now there will be an extra space if 'blue' is not set ('I like green .').

I like green{{#if:{{{blue|}}}| and blue}}.

Adding the space between the pipe ('|') and the word 'and' doesn't work. Any leading or trailing spaces from a parser function output are stripped, so this produces exactly the same output as the first example when 'blue' is true ('I like greenand blue.').

I like green{{#if:{{{blue|}}}|{{sp}}and blue}}.

This one works! By inserting the {{sp}} in the parser function output, the space is not stripped, and the correct output is given whether blue is set to true ('I like green and blue.') or not set at all ('I like green.').

Disabling default substitution[ویرایش]

Suppose you have a template, {{Example}}, that uses substitution, like this:

{{{{{subst|subst:}}}#if{{{condition|}}}|message}}

When the template is ویکی‌پدیا:تراگنجانش and saved, the result would be interpreted as:

{{subst:#if{{{condition|}}}|message}}

You could override the substitution by setting the 'subst' attribute to {{sp}}:

{{Example| subst={{sp}} }}

Now the result would be interpreted as:

{{ #if{{{condition|}}}|message}}

The extra blank space preceding the '#if' would not affect the template at all (except to suppress the default substitution)

See also[ویرایش]

  • {{space}}: A similar template that is often more useful except when working with parser functions
  • {{fdw-iw}}: A template that uses {{sp}} with parser functions
https://fa.wikipedia.org/wiki/%D8%A7%D9%84%DA%AF%D9%88:Sp
fa.wikipedia.org
crawl=CC-MAIN-2019-39
52876
application/http; msgtype=response
sha1:2B4DK6X4P5ZDIFEJNS2YPHDE3IVIVGQ7
<urn:uuid:42e7e634-22bb-445a-97b8-dce22b1b85be>
2019-09-16T20:34:31Z
208.80.154.224
text/html
sha1:ZZ4BVZD4NCJK734NCMPJQSZI7QL4CF4V
<urn:uuid:9034a928-372d-44da-b61c-b52e85dda98a>
https://fa.wikipedia.org/wiki/%D8%A7%D9%84%DA%AF%D9%88:Sp
response
<urn:uuid:5a06bea5-3ef8-4f5d-97b5-b6554745a4f4>
isPartOf: CC-MAIN-2019-39
publisher: Common Crawl
description: Wide crawl of the web for September 2019
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-201.ec2.internal
software: Apache Nutch 1.15 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/