Add textContent to HTML via MediaWiki template

泄露秘密 提交于 2019-12-25 00:17:11

问题


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>


来源:https://stackoverflow.com/questions/57048049/add-textcontent-to-html-via-mediawiki-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!