模板討論:Infobox

出自H萌娘
於 2021年6月24日 (四) 10:19 由 imported>MJH 所做的修訂 →‎由MJH提出的对Template:Infobox的编辑请求
跳至導覽 跳至搜尋

由MJH提出的對Template:Infobox的編輯請求

將以下內容:

{{Infobox/brick|column1= {{{Row 1 title|}}}|column1 style= {{{Row 1 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 1 info|}}}|column2 style={{{Row 1 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 2 title|}}}|column1 style= {{{Row 2 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 2 info|}}}|column2 style={{{Row 2 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 3 title|}}}|column1 style= {{{Row 3 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 3 info|}}}|column2 style={{{Row 3 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 4 title|}}}|column1 style= {{{Row 4 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 4 info|}}}|column2 style={{{Row 4 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 5 title|}}}|column1 style= {{{Row 5 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 5 info|}}}|column2 style={{{Row 5 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 6 title|}}}|column1 style= {{{Row 6 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 6 info|}}}|column2 style={{{Row 6 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 7 title|}}}|column1 style= {{{Row 7 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 7 info|}}}|column2 style={{{Row 7 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 8 title|}}}|column1 style= {{{Row 8 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 8 info|}}}|column2 style={{{Row 8 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 9 title|}}}|column1 style= {{{Row 9 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 9 info|}}}|column2 style={{{Row 9 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 10 title|}}}|column1 style= {{{Row 10 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 10 info|}}}|column2 style={{{Row 10 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 11 title|}}}|column1 style= {{{Row 11 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 11 info|}}}|column2 style={{{Row 11 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 12 title|}}}|column1 style= {{{Row 12 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 12 info|}}}|column2 style={{{Row 12 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 13 title|}}}|column1 style= {{{Row 13 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 13 info|}}}|column2 style={{{Row 13 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 14 title|}}}|column1 style= {{{Row 14 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 14 info|}}}|column2 style={{{Row 14 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 15 title|}}}|column1 style= {{{Row 15 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 15 info|}}}|column2 style={{{Row 15 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 16 title|}}}|column1 style= {{{Row 16 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 16 info|}}}|column2 style={{{Row 16 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 17 title|}}}|column1 style= {{{Row 17 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 17 info|}}}|column2 style={{{Row 17 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 18 title|}}}|column1 style= {{{Row 18 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 18 info|}}}|column2 style={{{Row 18 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 19 title|}}}|column1 style= {{{Row 19 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 19 info|}}}|column2 style={{{Row 19 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 20 title|}}}|column1 style= {{{Row 20 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 20 info|}}}|column2 style={{{Row 20 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 21 title|}}}|column1 style= {{{Row 21 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 21 info|}}}|column2 style={{{Row 21 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 22 title|}}}|column1 style= {{{Row 22 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 22 info|}}}|column2 style={{{Row 22 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 23 title|}}}|column1 style= {{{Row 23 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 23 info|}}}|column2 style={{{Row 23 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 24 title|}}}|column1 style= {{{Row 24 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 24 info|}}}|column2 style={{{Row 24 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 25 title|}}}|column1 style= {{{Row 25 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 25 info|}}}|column2 style={{{Row 25 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 26 title|}}}|column1 style= {{{Row 26 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 26 info|}}}|column2 style={{{Row 26 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 27 title|}}}|column1 style= {{{Row 27 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 27 info|}}}|column2 style={{{Row 27 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 28 title|}}}|column1 style= {{{Row 28 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 28 info|}}}|column2 style={{{Row 28 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 29 title|}}}|column1 style= {{{Row 29 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 29 info|}}}|column2 style={{{Row 29 infostyle| {{{Row infostyle|}}} }}} }}
{{Infobox/brick|column1= {{{Row 30 title|}}}|column1 style= {{{Row 30 titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row 30 info|}}}|column2 style={{{Row 30 infostyle| {{{Row infostyle|}}} }}} }}

修改為:

{{#vardefine:maxidx|0}}{{#forargs:Row |k|v|{{#if:{{#vardefineecho:idx|{{str_match|str={{#var:k}}|ptn=^(%d+) title$}}}}|
{{#ifexpr:{{#var:maxidx}}<{{#var:idx}}|{{#vardefine:maxidx|{{#var:idx}}}}}}
}}}}<!-- 这里先loop一遍记录maxidx是为了绕过#forargs依赖参数顺序的特性,保证row 1 title始终排在row 2 title前面。 -->
{{#invoke:loop|loop|time=1|{{#var:maxidx}}
|do=<nowiki>
{{Infobox/brick|column1= {{{Row {{#var:time}} title|}}}|column1 style= {{{Row {{#var:time}} titlestyle| {{{Row titlestyle|}}} }}} bgcolor="{{{left-column-color|#E0FFFF}}}" 
|column2= {{{Row {{#var:time}} info|}}}|column2 style={{{Row {{#var:time}} infostyle| {{{Row infostyle|}}} }}} }}
</nowiki>
}}

此外,關於對#forargs依賴參數順序的特性的批判,參見User:MJH/evilforargs。——M.Me. J.Jot something down. H.History.【萃】 2021年6月16日 (三) 12:57 (CST)回覆[回覆]

@MJH使用後顯示:表達式錯誤:無法識別的標點「[」,腳本錯誤:函數「loop」不存在。--悠遠的蒼穹 (Talk with me!) 2021年6月24日 (四) 09:33 (CST)回覆[回覆]
欸欸?!我可以看一下對應的沙盒頁面固定連結嗎…… --M.Me. J.Just a chat. H.Heritage.【觀】{{#forargs:}} is evil! 2021年6月24日 (四) 09:35 (CST)回覆[回覆]
似乎{{#invoke:loop|loop|應該改為{{#invoke:loop|main|,還有我沒在這裡實驗,不過我想你應該知道我會在哪裡實驗。。。--悠遠的蒼穹 (Talk with me!) 2021年6月24日 (四) 09:37 (CST)
@MJH你退群後,我失去了你的QQ,你可以加我的 QQ:850710247--悠遠的蒼穹 (Talk with me!) 2021年6月24日 (四) 09:42 (CST)回覆[回覆]
是不是那邊的loop模塊實現不一樣?這邊的loop模塊裡面loop和main是完全等價的,loop換成main沒道理造成任何影響。 --M.Me. J.Jot something down. H.Hard work.【晉】{{#forargs:}} is evil! 2021年6月24日 (四) 09:44 (CST)回覆[回覆]
那裡的模塊沒更新,剛才我更了就好了,現在只顯示:表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。表達式錯誤:無法識別的標點「[」。
你在那邊ping我一下我看看吧,有點怪…… --M.Me. J.Join the talk. H.Hard work.【艮】{{#forargs:}} is evil! 2021年6月24日 (四) 09:56 (CST)回覆[回覆]

@MJH情況就是這樣,不要看模板下面的介紹文件,那個是嵌入萌百的,請查看嵌入此模板的條目--<img src="https://www.hmoegirl.com/images/avatars/574894/128.png?ver=1598093246" style="width: 2.5em;border-radius: 50%;"/> =海豚=留言 · 貢獻 · 討論) 2021年6月24日 (四) 10:05 (CST)回覆[回覆]

Template:海豚= 我找到問題了,H萌沒有{{str_match}}。 --MJH討論) 2021年6月24日 (四) 10:19 (CST)回覆[回覆]