淡水鱼什么鱼最好吃| 什么门关不上| 化学性肝损伤是什么意思| 办低保需要什么条件| pm2.5是什么意思| 鸡飞狗跳的意思是什么| 减肥饿了可以吃什么| 钱丢了预示着什么| 汗蒸有什么好处| 夜尿多吃什么药效果好| 来龙去脉指什么生肖| 大米发霉是什么样子| 含羞草为什么会害羞| 年纪是什么意思| 梦见谈恋爱很甜蜜是什么意思| 分泌物呈褐色是什么原因| 元朝是什么民族| 鬼冢虎属于什么档次| 左眼角有痣代表什么| 口腔长期溃疡是什么原因引起的| 受虐倾向是什么意思| 多动症是什么原因造成的| 护士资格证什么时候考| 药店最怕什么样的举报| 白血球低吃什么补得快| 咽炎有什么症状| 军加皮念什么| 梦见别人家拆房子是什么预兆| 军长是什么军衔| 97年的属什么| 扇贝不能和什么一起吃| 氨咖黄敏胶囊是治什么的| 全飞秒是什么| 高血脂吃什么食物最好| 子宫内膜不均匀是什么意思| 为什么会莫名其妙流鼻血| 肾病综合征是什么病| 圆圆的什么| 泸州老窖是什么香型| 安康鱼长什么样| 派出所所长是什么级别| 性生活是什么感觉| 精制盐是什么盐| 老年人心跳过快是什么原因| 肺气虚吃什么中成药| 女性排卵期有什么表现| 一见倾心什么意思| 手的皮肤黄是什么原因| 门当户对指的是什么| 竹字五行属什么| 梦见打狼是什么预兆| 痴男怨女是什么意思| 回头是岸是什么生肖| 酸野是什么| 五月初十是什么星座| 叫姑姑是什么关系| 夜盲症是什么| 银耳为什么助湿气| 正常人为什么会低血糖| 心律不齐什么症状| 驴友是什么意思| 五十岁叫什么之年| 唇炎挂什么科| 心脏早博吃什么药好| 剁椒鱼头是什么鱼头| 后羿射日告诉我们什么道理| 殉葬是什么意思| 圣诞节适合送什么礼物| 小孩晚上睡觉流口水是什么原因| 血清和血浆有什么区别| 宫颈炎吃什么药好得快| 猪展是什么| 海绵体充血不足吃什么药| 非特异性t波异常是什么意思| 股票举牌什么意思| 机器灵砍菜刀是什么意思| 尿隐血十1是什么意思| 多潘立酮片是什么药| 路政是干什么的| hpv亚型是什么意思| 固涩是什么意思| 长痘痘是什么原因| 菩提心是什么意思| 难入睡是什么原因| 不明原因发烧挂什么科| 吃什么补镁| 乙醇是什么东西| ifyou什么意思| 姐妹是什么生肖| 114514是什么梗| 圣代是什么| 黑枸杞的功效是什么| 面条是什么做的| 鼻窦炎用什么药好| 脚抽筋是什么原因引起的| 氧化钙是什么| 白萝卜煮水喝有什么功效| 身体皮肤痒是什么原因| 睡觉打呼噜是什么病| 查肾功能需要做什么检查| 就藩什么意思| 头部神经痛吃什么药好| 空调出的水是什么水| 2017是什么年| 三焦不通吃什么中成药| 屁股疼痛是什么原因引起的| 苍苍什么| 黄水病是什么病| 水淀粉是什么粉| 胃部彩超能检查出什么| 宝玑手表是什么档次| 什么产品祛斑效果最好| hpv疫苗是什么| 女用避孕套是什么样的| 查甲功是什么意思| 清洁度1度是什么意思| 吃什么英语怎么说| 肠绞痛什么原因引起的| 男人少一个睾丸有什么影响| 幽门螺旋杆菌有什么危害| 熟褐色是什么颜色| 吃什么药能死| 无头鱼是什么鱼| 头上出汗是什么原因| 10月15号是什么星座的| 黄体功能不全是什么意思| 扩招是什么意思| 中暑什么感觉| 急性阑尾炎什么症状| 为什么会有子宫肌瘤| 咽炎吃什么药效果最好| 偏头疼吃什么药效果好| 肢体麻木是什么原因| 新房开火有什么讲究| 微恶风寒是什么意思| 什么是清宫| 背疽是什么病| 看望病人送什么花合适| 初恋什么意思| 爱爱是什么感觉| 活色生香什么意思| 三伏是什么意思| 肛塞有什么用| 安德玛是什么牌子| 大眼角痒用什么眼药水| 大胯疼是什么原因引起| 左侧肋骨疼是什么原因| 巨蟹座和什么最配| 手指关节肿痛用什么药| 上头是什么意思| 女生喝什么茶对身体好| 1967年是什么年| 五月十六日是什么星座| 粉色裤子搭什么上衣| 脉弱是什么原因导致的| 属猪的守护神是什么菩萨| 醋酸是什么| 宫颈筛查是什么| 泡泡像什么| 男人艾灸什么地方壮阳| 慢脚是什么| 脑壳疼是什么原因| 眼皮红肿是什么原因| 小孩子发烧吃什么药| 补肾吃什么药最好| 主治医生是什么级别| 片的第二笔是什么| 父亲节什么时间| 长脸型适合什么样的发型| 晚上九点多是什么时辰| 惜败是什么意思| 脊膜瘤是什么样的病| 不以为然的意思是什么| 甘油三酯是什么意思| 反流性食管炎吃什么食物好| 美国人的祖先是什么人| 嘴子是什么意思| 口是心非是什么动物| 人肉什么意思| hcg阴性是什么意思| 什么是磁场| 睡觉为什么流口水| 反物质是什么东西| 刚怀孕有什么症状| 高温天气喝什么水最好| 安全起见是什么意思| 头孢治什么| 背痛去医院挂什么科| 什么的眼睛| 野生葛根粉有什么功效| 腹胀屁多是什么原因| 孕妇缺碘对胎儿有什么影响| 三叉神经痛挂什么科| 发小是什么意思| 多种维生素什么牌子的效果最好| 藏语扎西德勒什么意思| 梅菜在北方叫什么菜| 不以为然的意思是什么| ug是什么单位| 想吃辣是身体缺乏什么| 次方是什么意思| 茭白不能和什么一起吃| 当志愿者有什么好处| 12月份是什么星座| 维生素e的功效与作用是什么| 大象的天敌是什么动物| 处女和什么座最配对| 什么身是胆| 五谷都有什么| 全脂牛奶是什么意思| 花圃是什么意思| 梦见摘丝瓜有什么预兆| 扩词是什么| 什么是早谢泄图片| 含羞草为什么会害羞| 脑梗是什么原因造成的| 彩霞是什么意思| 县委副书记是什么级别| 天意不可违是什么意思| 血小板低吃什么好| 三伏天什么时候最热| 缓释是什么意思| 凝胶是什么| 举足轻重什么意思| 什么是电解质水| 唐僧的袈裟叫什么| 安道尔微信暗示什么| 荷叶茶有什么功效和作用| 代发什么意思| 屎发黑是什么原因| 吃什么奶水多| 止语是什么意思| rt表示什么意思| 学前班是什么意思| 煮黑豆吃有什么功效| 两个土念什么字| 白细胞计数偏高是什么意思| 39属什么生肖| 排尿带血是什么原因| 泌尿外科看什么病| 中国国粹是什么| 银行卡为什么会被冻结| cdfi未见明显血流信号是什么意思| 早上吃黄瓜有什么好处| 新生儿头发稀少是什么原因| 阴囊长白毛是什么原因| 做什么生意好赚钱| 子宫肌瘤是什么症状| 为什么会长阴虱| 小乌龟死了有什么预兆| hpv不能吃什么食物| 孕早期吃什么有利于胎心胎芽发育| 生精补精吃什么药最快| 女人为什么会得霉菌| 拔了尿管尿不出来有什么好办法| 促甲状腺激素低是什么原因| 拂是什么生肖| 身份证号码的数字代表什么意义| 吃土豆有什么好处| 去澳门需要什么证件| 减肥吃什么油| 杨梅用什么酒泡最好| 备孕需要做些什么准备| tct什么意思| 百度Jump to content

蓝港互动推“台网游”联动手游《莽荒纪》 年内与

From Wikipedia, the free encyclopedia
百度 搭伙生活,晚年更幸福受访专家:中国老年学和老年医学学会老年心理专业委员会秘书长杨萍中国人民大学老年学研究所所长杜鹏人类平均预期寿命正以每年约3个月的幅度增长,过去十年间全球百岁以上人口数量增加了71%,英国神经生物学家科林·布雷科摩尔认为,人类寿命有望延长至120岁。

Substitution is a function whereby, when an editor saves a page, an item in the wikicode is permanently replaced with its current value. In particular, templates and magic words can be substituted, as an alternative to transclusion. The difference is that when a template is substituted on a page, its appearance on that page will no longer be affected by later changes made to the template itself (as is the case in a transcluded template).

Substitution is done using the subst: modifier after the double opening braces. For example, to substitute the template {{Article for deletion}}, type {{subst:Article for deletion}}. You can check the resulting wikitext before saving by clicking "Show changes" (and see what the page will look like by clicking "Show preview").

Variables and parser functions can also be substituted, meaning that their current value will be recorded permanently on the page – they will not be re-evaluated whenever someone views the page.

When to use substitution

[edit]

Generally speaking, templates are transcluded rather than substituted, although there are some that are specifically designed to be substituted (and may not work if transcluded). Some reasons for substituting templates include:

  • making the resulting page independent of future changes to the template
  • enabling other automatic replacements to occur (for example, a template may contain four tildes, which will be replaced by the user's signature and timestamp provided the template is substituted)
  • enabling the page to be copied to another project without copying the template
  • making page rendering faster for the server
  • making the correspondence between wikitext and rendered page easier to understand (the opposite may also apply)

Disadvantages of substitution may include:

  • Updates to the template will not be reflected on the target page
  • The resulting wikitext is longer and more complicated
  • Other users cannot see that the text was produced using a template (and will not learn to use the template)
    • Many templates add a hidden comment such as <!-- Template:Foo --> to the end of their output to mitigate this issue.

Time-dependent variables are substituted to make the rendered page independent of the time at which it is viewed. Substituting page-dependent variables makes the resulting wikitext independent of renaming of the page and of copying to another page.

For more detailed guidance, including lists of templates which should or should not be substituted, see Wikipedia:Substitution.

Syntax

[edit]

To substitute a template, use the same syntax as for transclusion, but include subst: after the opening double braces. For example, to substitute the template {{afd}}, type {{subst:afd}}. Parameters can be included as in the case of transclusion, for example {{subst:afd|Some article}}.

Pages not in the template namespace can also be substituted, e.g. {{subst:User:Cleverclogs/My box}}. To substitute the current content of a page in mainspace (i.e. one with no namespace prefix), two colons are required, as in {{subst::Page}}. If a substituted page or template does not exist, the entire expression (with braces and subst:) will remain unchanged in the wikitext and on the page.

Use the same syntax to substitute variables and parser functions, e.g. {{subst:PAGENAME}} or {{subst:#switch:{{NUMBEROFADMINS}}|1=Foo|1000=Bar|#default=Baz}}.

There may be whitespace between the opening braces and the "subst:". However it is recommended not to have any space or newlines immediately after the "subst:", as this will not work in every case.

Technical implementation

[edit]

Substitution is part of the process performed on saving a page, and causes the wikitext saved as a result of the edit to differ from the text which the user actually entered in the edit window. Other replacements performed during this process include expansion of links using the pipe trick, and replacement of multiple tildes with signatures and timestamps.

This means that substitution necessarily occurs before any actions performed at the time of page rendering (conversion of the stored wikitext to HTML). In particular, substitutions are done before transclusions. So typing {{subst:Help:L{{in(tut)}}k}} will not do substitution, even though {{in(tut)}} returns the text "in" and Help:Link exists. The transclusion of {{in(tut)}} has not yet taken place when the substitution is attempted. However, replace {{in(tut)}} with {{subst:in(tut)}}, and both substitutions will be performed in the expected order.

Similarly:

  • Typing {{subst:#if:{{x0}}|yes|no}} gives the wikitext "yes", even though {{x0}} is an empty template, since the conditional parameter evaluates to the non-empty string "{{x0}}". However {{subst:#if:{{subst:x0}}|yes|no}} produces "no", since the inner substitution is performed first.
  • Typing {{subst:#expr:2*{{{p|3}}}}} returns Expression error: unrecognised punctuation character "{", as the undefined parameter {{{p}}} has not been replaced by its default value (3) when the substitution occurs.
  • If {{t6}} contains the text "t2|a", then {{ {{subst:t6}} }} will produce the wikitext "{{ t2|a }}", rendered as "[[w:List of people by name: a{{{2}}}|a{{{2}}}]]" Contrast this with the behaviour of {{ {{t6}} }}, which is rendered as "{{ t2|a }}", because the parser does not reinterpret the pipe as a separator during the non-substituted expansion stage. (Similarly, {{subst:{{subst:t6}} }} gives the wikitext {{subst:t2|a }}, which only on the next edit will be substituted with [[w:List of people by name: a{{{2}}}|a{{{2}}}]].)

Clicking the "Show changes" button during editing shows the wikitext that will result after substitution and other immediate replacements are carried out. Clicking "Show preview" shows what the rendered page will look like after these replacements.

If a page substitutes itself (e.g. in the noinclude part of a template page) it substitutes the old version, as it was before the current edit.

If the expansion of a substituted template itself contains instances of the subst: syntax, then the substitutions are performed recursively. However substitution is not automatically recursive – if a substituted template contains ordinary transclusions or variables and parser functions which are not explicitly substituted, then these will not be substituted.

Note also that if instances of the subst: syntax appear in a template that is being transcluded, then they will be rendered unchanged (as "{{subst:...}}"), since no substitution in wikitext is possible at the rendering stage. This feature can be exploited to control template behaviour (see § Making templates behave differently when transcluded or substituted). However, it may be inconvenient when a template is designed to be possible to transclude as well as substitute – in this case safesubst: can be used instead of subst: (see § The safesubst: modifier).

The safesubst: modifier

[edit]

The subst: modifier can be replaced by the alternative modifier safesubst:. The two have the same behaviour, except when they are encountered during non-substituted expansion (transclusion or direct viewing) of a template. In such a situation, the code {{subst:...}} remains unparsed, whereas the {{safesubst:...}} is treated as if no modifier were present – and so the subtemplate is transcluded or the variable or parser function evaluated.

Hence the safesubst: modifier is used in the code of templates which are designed to produce recursive substitution when substituted; but that are also intended to work when transcluded or simply to be viewed directly. Contrasted with using the subst: modifier, such templates would break in such cases of transclusion (and possibly on direct viewing).

For details on how to implement this (in particular, how to prevent the substitution from being performed as soon as the template code is saved), see § Recursive substitution.

Recursive substitution

[edit]

As mentioned above, substitution is not automatically recursive. So if a substituted template has code containing transclusions of other templates and parser functions, that code will be copied "as is" into the resulting wikitext – the transcluded items will not themselves be substituted.

To make substitution work recursively, you must include the subst: syntax in the code of the calling template. However, you cannot do this by simply typing "subst:" within the template, as the substitution would then be performed as soon as the template is saved. There are two ways to work around this problem:

  • Use subst:<noinclude /> in place of plain subst:. The noinclude tag breaks up the substitution syntax when the template is saved, but will be stripped away when it is later substituted, allowing the inner substitution to take effect. Alternatively, a larger part of the template code can be wrapped in <onlyinclude>...</onlyinclude>. Then the wrapped code is ignored on the template page itself but not when it is transcluded.
  • Make "subst:" the possible value of an expression containing a parameter, such as {{{subst-foo|subst:}}}, which will evaluate to "subst:" provided the parameter subst-foo is not set. This is a more flexible solution, as it allows the behaviour to be controlled via the parameter. For example, such a template might be called using {{subst:Templatename|subst-foo=|...}}, assigning the parameter an empty value and thus turning off the second level of substitution. If it is not planned to use the parameter, the parameter name is often chosen to be the empty string, giving {{{|subst:}}}, but this can have unexpected results if a value is assigned to the empty string parameter (e.g. {{Templatename|=foo}}).

To ensure that the template will still work as intended if it is transcluded instead of substituted, use safesubst: instead of subst:. This also applies if the template is also to be viewed directly, on its own page (although in this case, if the first of the above methods is used, plain subst: will still work, as the includeonly tags will cause the parser to ignore the subst: on direct viewing).

To see what a template will produce when fully expanded, without the need to explicitly substitute all subtemplates etc., the Special:ExpandTemplates tool can be used.

For more information, see the Recursive conversion of wikitext help page at Meta. See also Help:Calculation § Substitution, m:Template:Example table with computations, with optional substitution (backlinks edit), and the feature request at substall.

Recursive substitution in guided tours

[edit]

Guided tours can make posts on behalf of users, such as automatically posting the contents of a wiki page onto a talk page. Unlike normal substitution or transclusion, however, this function of guided tours does not respect <includeonly>...</includeonly> and similar markup. To make recursive substitution work via guided tour posting, you can use the Delaying substitution with Template:subst method.

An example of recursion in action

[edit]

This is an example using the actual Template:Like, and a hypothetical Template:Foo. You are attempting to include the Template:Foo, and indirectly the Template:Like, on a third page through transclusion and substitution. Template:Like displays this symbol: ?? Like

For example, let's say the Template:Foo contained the wikitext {{Like}}. If you then transclude it, using the wikitext {{Foo}}, this will transclude the Template:Like as you would expect. But if you use the wikitext {{subst:Foo}}, when you save it, you find the wikitext {{Like}} substituted rather than the wikitext of the page Template:Like. The substitution has not been recursive.

An example of recursion would be if the Template:Foo contained the wikitext {{{{{|safesubst:}}}Like}}. Now if you transclude it, using the wikitext {{Foo}}, this will transclude the Template:Like just as before. And if you save {{subst:Foo}} it will substitute the full actual wikitext of the Template:Like. You have therefore achieved recursive substitution.

Further examples

[edit]

Note: {{!}} substitutes to |.

Wikitext of Template:Foo When you view Template:Foo,
it looks like:
The result of {{Foo}}
if included on this page
The result of {{subst:Foo}}
if included on this page
saves as: renders as: saves as: renders as:
{{!}}

{{PAGENAME}}

{{#if: 1 | yes | no}}
|

Foo

yes

{{Foo}}
|

Substitution

yes

{{!}}

{{PAGENAME}}

{{#if: 1 | yes | no}}
|

Substitution

yes

{{{{{|subst:}}}!}}

{{{{{|subst:}}}PAGENAME}}

{{{{{|subst:}}}#if: 1 | yes | no}}
{{subst:!}}

{{subst:PAGENAME}}

{{subst:#if: 1 | yes | no}}

{{Foo}}
{{subst:!}}

{{subst:PAGENAME}}

{{subst:#if: 1 | yes | no}}

|

Substitution

yes
|

Substitution

yes

{{{{{|safesubst:}}}!}}

{{{{{|safesubst:}}}PAGENAME}}

{{{{{|safesubst:}}}#if: 1 | yes | no}}
|

Foo

yes

{{Foo}}
|

Substitution

yes

|

Substitution

yes
|

Substitution

yes

Making templates behave differently when transcluded or substituted

[edit]

Sometimes it is desirable to make a template behave differently when substituted rather than when transcluded. A common trick for doing this is to use an expression like {{{{{subst|subst:}}}ns:0}}. This evaluates to the empty string if the template is being substituted (since the inner substitution takes effect, giving the prefix of namespace 0, which is empty), but to "{{subst:ns:0}}" if the template is being transcluded (since substitution cannot take place after transclusion).

A common application is in templates which are designed only to be substituted, to make them produce a warning if they are mistakenly transcluded instead. This is done in templates like {{prod}}, which are designed to produce a timestamp (e.g. for adding pages to dated categories), and will not be able to do this if transcluded.

A template, {{issubst}}, has been created to simplify this. It returns "yes" if substitution is being performed, or the empty string otherwise. This can then be used as the parameter of a conditional parser function to make the template display a warning method if it is being transcluded, or to otherwise change the behaviour of a template depending on whether it is being transcluded or substituted.

Documenting substitution

[edit]

Usage of a template through subst: does not automatically show up in page histories. Therefore, providing the line of wikitext containing "subst:" in the edit summary is especially useful.

Also, pages with a substituted template do not show up in backlinks, and the template does not appear in the list of transcluded templates on the edit page. The template could add pages to a category to track substitutions, but listing this category on a page may clutter the list of content-based categories the page is in. Also, comments outside noinclude tags are included in the wikitext. Thus a comment can be used to mention the template. Substitution of parameters does not work inside comments, but a workaround for this is to begin an intended comment with <!<noinclude />-- so that it turns into a comment once transcluded.

Limitation

[edit]

Substitution is not available inside <ref>...</ref> and <gallery>...</gallery> tags. If you write {{subst:foo}}, it is not substituted nor transcluded, but remains as-is (it's a known bug, see T4700 and gerrit:272916 for current status).

However it is possible to bypass this limitation by using the magic word #tag. If you write, for instance, {{safesubst:#tag:ref|content of the reference}}, the content of the reference will be substituted and the {{#tag:ref|...}} will be replaced with <ref>...</ref>. A more concrete example: If you write for instance {{safesubst:#tag:ref|...Title=ExampleTitle|archivedate={{subst:TODAY}}|Edition=Hardcover...}} then the software will perform substitutions on the text within the last field and the {{#tag:ref|...}} will be replaced with <ref>...</ref>around the altered text, and the reference will be saved with the substitution; it'll be saved as "{{|...Title=ExampleTitle|archivedate=29 January 2016|Edition=Hardcover|...}}" with <ref>...</ref> around it. In other words, first the software will expand the templates and then place that expanded text within reference tags.

Templates for substitution

[edit]

See also

[edit]
云南简称是什么 乳房结节是什么原因引起的 做梦翻车了什么预兆 白细胞30是什么意思 过是什么结构的字
嘴巴里面起泡是什么原因引起的 松香对人体有什么危害 国师是什么生肖 guess什么意思 阿司匹林肠溶片什么时候吃最好
处cp是什么意思 接吻是什么感觉 骨骼惊奇什么意思 包粽子的叶子叫什么 什么的树枝
动人是什么意思 凤凰单枞是什么茶 绝非偶然是什么意思 肚子疼是什么原因引起的 反酸烧心吃什么药效果好
彩超无回声是什么意思hcv7jop6ns4r.cn 梦见自己怀孕大肚子是什么预兆hcv9jop5ns9r.cn 为什么会水肿hcv7jop6ns2r.cn 高血糖能吃什么水果ff14chat.com 梦到鱼是什么意思hcv8jop2ns1r.cn
1月7号什么星座hcv9jop2ns6r.cn 轻断食什么意思hcv8jop8ns6r.cn 为什么蚊子咬了会起包hcv8jop1ns7r.cn 公主病是什么意思hcv8jop4ns2r.cn 大便暗红色是什么原因hcv8jop3ns3r.cn
腺苷钴胺片治什么病hcv8jop0ns6r.cn 霉菌阴性是什么意思hcv7jop6ns8r.cn 小孩包皮挂什么科shenchushe.com 角膜塑形镜是什么dayuxmw.com 九月十三号是什么星座hcv8jop0ns1r.cn
冠状沟有白色分泌物是什么原因adwl56.com 阳虚是什么hcv9jop2ns5r.cn 脂膜炎是什么病hcv8jop0ns1r.cn 胎盘2级是什么意思hcv9jop0ns3r.cn 坐月子吃什么补气血hcv7jop6ns0r.cn
百度