通过 MediaWiki 模板将 textContent 添加到 HTML [英] Add textContent to HTML via MediaWiki template

查看:78
本文介绍了通过 MediaWiki 模板将 textContent 添加到 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个以希伯来字母 א (template:א) 命名的 MediaWiki 模板.其内容为:

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

<code></code>

我通过{{א|SOME_textContent}}调用它.

我希望在常规文本旁边显示单行代码,例如:

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

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

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

我的问题

我的问题是,在我使用上述模板调用保存页面后,我得到一个空的 标签内容 ().

为什么我得到空的 <code> 标签内容 (),而不是得到 SOME_textContent(我在调用之后给出的输入竖线 (|))?

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

模板页面代码:

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

模板页面输出:

{{{1}}}

文章页面代码:

{{א|=}}

文章页面输出:

{{{1}}}

推荐答案

根据定义,code 标签内的所有内容都不会被解析,因此您的参数将被解释为字符串.

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

不要使用 html 标记 ,而是像这样使用解析器函数 #tag:

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

{{#tag:code |{ { 电话代码区:970},{ 电话代码区:961},{ 电话代码区:98} } }}

{{#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>

这篇关于通过 MediaWiki 模板将 textContent 添加到 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆