Add textContent to HTML via MediaWiki template

2019-08-30 23:01发布

问题:

I have created a MediaWiki template named by the Hebrew letter א (template:א). Its content is:

<code></code>

I call it by {{א|SOME_textContent}}.

Desired state

I desire to show a single-line code iside regular text, for example:

הסימן הזה = הינו סימן שוויון

My problem

My problem is that after I save a page with the above template call, I get an empty <code> tag content ().

My question

Why do I get empty <code> tag content (), instead getting SOME_textContent (the input I gave in call after the vertical bar (|))?

Update - I tried this but didn't get desired state

Template page code:

<code>{{{1}}}</code>

Template page output:

{{{1}}}

Article page code:

{{א|=}}

Article page output:

{{{1}}}

回答1:

By definition, everything inside code tag will not be parsed, so your parameter is interpreted as string.

Instead of using html markup <code>, use parser function #tag like so:

{{#tag:code | { { phone code area: 970}, { phone code area: 961}, { phone code area: 98} } }}

So your template will look like:

 <includeonly>{{#tag:code| {{{1}}} }}</includeonly>


回答2:

A template won't magically insert its parameters unless you tell it. The correct template content would be

<code>{{{1}}}</code>