Help:Substitution: Difference between revisions

m
278 revisions imported from wikipedia:Help:Substitution: R to helpspace
m (278 revisions imported from wikipedia:Help:Substitution: R to helpspace)
 
(15 intermediate revisions by 12 users not shown)
Line 9:
[[Help:variable|Variable]]s and [[Help:parser function|parser function]]s 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.
 
<ref><ref><ref></ref></ref></ref>==When to use substitution==
Generally speaking, templates are [[WP:transclusion|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
Line 67:
To make substitution work recursively, you must include the <code>subst:</code> 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 <code><nowiki>subst:<noinclude/></nowiki></code> in place of plain <code>subst:</code>. 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.
exportovat*Make výchozí"subst:" aplikaci;the possible value of an expression containing a parameter, such as <code><nowiki>{{{subst-foo|subst:}}}</nowiki></code>, 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 <code><nowiki>{{subst:</nowiki>{{var|Templatename}}<nowiki>|subst-foo=|..}}</nowiki></code>, 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 <code><nowiki>{{{|subst:}}}</nowiki></code>.
*Make "subst:" the possible value of an expression containingimport * jako Reagovat z 'reagovat';
import '.. /styly/ui.css';
 
deklarovat funkce require ( path : string ) : any declare function require(path: string): any declare;
 
const App = ({}) => {
const textbox = React. useRef<HTMLInputElement>(nedefinováno);
 
const countRef = React. useCallback( (element: HTMLInputElement) => {
if (element) element. hodnota = '5';
textového pole. proud = prvek;
}, []);
 
const onCreate = React. useCallback(() => {
const count = parseInt(textovépole. aktuální. hodnota, 10);
rodiče. postMessage({pluginMessage: {typ: 'create-rectangles', count}, '*');
}, []);
 
const onCancel = Reagovat. useCallback(() => {
rodiče. postMessage({pluginMessage: {typ: 'cancel'}, '*');
}, []);
 
Reagovat. useEffect(() => {
Takto čteme zprávy odeslané z ovladače pluginu
okno. onmessage = (událost) => {
const { typ, zpráva } = událost. údaje. pluginMessage;
if (typ === 'create-rectangles') {
konzole. log('Figma říká: ${message}');
};
}
}, []);
 
Vrátit (
<Div>
<img src={require('.. /assets/logo.svg')} />
<h2>Tvůrce obdélníku</h2>
<P>
Počet: <vstupní ref={countRef} />
</P>
<tlačítko id="vytvořit" onClick={onCreate}>
Vytvořit
</Tlačítko>
<tlačítko onClick={onCancel}>Zrušit</tlačítko>
</Div>
);
};
 
exportovat výchozí aplikaci; a parameter, such as <code><nowiki>{{{subst-foo|subst:}}}</nowiki></code>, 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 <code><nowiki>{{subst:</nowiki>{{var|Templatename}}<nowiki>|subst-foo=|..}}</nowiki></code>, 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 <code><nowiki>{{{|subst:}}}</nowiki></code>.
 
'''To ensure that the template will still work as intended if it is transcluded instead of substituted, use <code>safesubst:</code> instead of <code>subst:</code>.''' 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).
Line 275 ⟶ 228:
** {{tim|last edit}} – example: <span class="plainlinks">[{{fullurl:Special:Contributions|limit=1&target={{urlencode:Example User}}}} last edit]</span>
** {{tim|page history}}
* [[Wikipedia:WikiProject Check Wikipedia#Template programming element|WikiProject Check Wikipedia §&nbsp;Template programming element]] lists articles where templates were substituted rather than transcluded.{{dead link|date=July 2011}} {{link note|note=According to the Wayback Machine, [//web.archive.org/web/20100528224125/http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Check_Wikipedia the last time this link worked] was May 2010. It appears to have been removed since then. Perhaps [https://toolscheckwiki.wmflabstoolforge.org/checkwiki/cgi-bin/checkwiki.cgi?project=enwiki&view=only&id=34 this tools page] may help find articles substituted rather than transcluded?}}
 
{{Wikipedia template messages}}