Template:Error

Revision as of 12:29, 1 November 2024 by Selfice (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
[ View | Edit | History | Purge ]Documentation page

This template uses Module:Error, this script is written in Lua.
For more details, please refer to Wikipedia:Lua and Extension:Scribunto.

此模板用于显示一个类似于解析器错误的红色文字。

用法

|1=用于指定显示的内容。

  • {{error|An exemplary error}} → An exemplary error
  • 对比解析器错误:{{#expr:Foo}}Expression error: Unrecognized word "foo".

如果未指定|1=,将不会显示任何内容,但仍然可以被{{#iferror:}}检测到。

使用了此模板的页面会被添加到分类Category:页面内有Error模板指定的错误。可以设置|nocat=使页面不加入分类。

#iferror

此模板会被解析器{{#iferror:}}检测到:

  • {{#iferror: {{error|Foo}} | {{c|yes}} | {{c|no}} }}Template:C
  • {{#iferror: {{error}} | {{c|yes}} | {{c|no}} }}Template:C

标签

用于包含错误信息的标签可以用|tag=设置,但只接受spandivpstrong这些值,因为{{#iferror:}}解析器只会解析这些标签。默认值为strong

源代码 效果
ABC {{error|An exemplary error demo no tag (default)}} XYZ ABC An exemplary error demo no tag (default) XYZ
ABC {{tag=span:error|An exemplary error demo span}} XYZ ABC An exemplary error demo span XYZ
ABC {{tag=div:error|An exemplary error demo div}} XYZ ABC
An exemplary error demo div
XYZ
ABC {{tag=p:error|An exemplary error demo p}} XYZ ABC

An exemplary error demo p

XYZ
ABC {{tag=strong:error|An exemplary error demo strong}} XYZ ABC An exemplary error demo strong XYZ

en:Template:Error

[ View | Edit | History | Purge ]The above documentation is transcluded from Template:Error/doc.