本模版的作用是讓兩部分內容只顯示一者而隱藏另一者,並提供切換按鈕。

參數說明 編輯

{{SwitchDisplay
| id = 
| shown-tab = 
| shown-tab-style = 
| hidden-tab = 
| hidden-tab-style = 
| split = 
| split-style = 
| switch = 
| switch-style = 
| shown = 
| shown-style = 
| hidden = 
| hidden-style = 
}}
  • id可以為任意字符串(但不能包含空格),但必須與相同頁面中其他本模版的id值都不重複,否則會顯示錯亂。
  • shown-tab為內容上方的說明文字,頁面載入時顯示。
  • hidden-tab為內容上方的說明文字,頁面載入時隱藏。
  • switch為切換按鈕的顯示文字,默認為「切換」。
  • split為shown-tab、hidden-tab與switch之間的分隔符,默認為「-」。
  • shown為頁面載入時顯示的內容。
  • hidden為頁面載入時隱藏的內容。
  • shown-tab-style為shown-tab的CSS風格。
  • hidden-tab-style為hidden-tab的CSS風格。
  • switch-style為switch的CSS風格。
  • split-style為split的CSS風格。
  • shown-style為shown的CSS風格。
  • hidden-style為hidden的CSS風格。

樣例 編輯

{{SwitchDisplay
| id = 0
| shown-tab = '''Python 3.x'''
| shown-tab-style = color:blue
| hidden-tab = '''Python 2.x'''
| hidden-tab-style = color:red
| shown = 
<source lang="python">
name = input()
print("Hi", name)
</source>
| hidden = 
<source lang="python">
name = raw_input()
print "Hi", name
</source>
}}

效果 編輯

Python 3.xPython 2.x - 切換

name = raw_input()
print "Hi", name
name = input()
print("Hi", name)