模組討論:CGroupViewer
外观
Temp3600在话题“編輯請求 2020-01-06”中的最新留言:5年前
編輯請求 2020-01-06
![]() | 正在請求他人代為編輯受保護的頁面(编辑:仅允许自动确认用户;移动:仅允许管理员(保护日志)) 注意:本模板不是用於請求開放頁面給予編輯,相關請求請至请求解除保护頁申請;本模板是用於請求可以編輯的用户幫忙修改內容。 請求時請列明理由及內容,確保修改有共識基礎及沒有爭議,否則請先在受保護頁面的討論頁進行討論。(工具:處理、申請解除保護) 如果您想直接展示给管理员修改后的页面及清楚地列出编辑差异,请将本模板改为 {{Editprotected|patch=}} ,点击「显示预览」并按照提示进一步操作。 |
把函數main改成這樣:
function z.main( frame )
local name = frame.args[1]
if not name or name == '' then
return ''
end
local data = require( 'Module:CGroup/' .. name )
if type( data ) ~= 'table' or not data.name or data.name == '' then
return error.error{ '指定-{zh-hans:模块;zh-hant:模組}-“' .. name .. '”不是有效的转换组' }
end
if data.name ~= name then
return frame:expandTemplate{ title = 'Template:CGroup redirect', args = { 'Module:CGroup/' .. data.name } }
end
local text = '<strong>-{H|zh-hans:模块;zh-hant:模組}-以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“' .. data.description .. '”。</strong>\n\n'
for i, v in ipairs( data.content ) do
if v.type == 'text' then
text = text .. makeText( frame, v )
elseif v.type == 'item' then
text = text .. makeItem( frame, v )
end
end
text = text .. '[[Category:公共轉換組模板|' .. name .. ']][[Category:公共转换组模块|' .. name .. ']]'
return text
end
-- Sunny00217 2020年1月6日 (一) 15:21 (UTC)
未完成,嘗試修改後部分頁面出現以下錯誤:「Lua錯誤:not enough memory。」。--Xiplus#Talk 2020年1月6日 (一) 23:01 (UTC)
那如果改成這樣呢:
function z.main( frame )
local name = frame.args[1]
if not name or name == '' then
return ''
end
local data = require( 'Module:CGroup/' .. name )
if type( data ) ~= 'table' or not data.name or data.name == '' then
return error.error{ '指定-{zh-hans:模块;zh-hant:模組}-“' .. name .. '”不是有效的转换组' }
end
if data.name ~= name then
return frame:expandTemplate{ title = 'Template:CGroup redirect', args = { 'Module:CGroup/' .. data.name } }
end
local pieces = { '-{H|zh-hans:模块;zh-hant:模組}-<strong>以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“' .. data.description .. '”。</strong>\n\n' }
for i, v in ipairs( data.content ) do
if v.type == 'text' then
table.insert( pieces, makeText( frame, v ) )
elseif v.type == 'item' then
table.insert( pieces, makeItem( frame, v ) )
end
end
table.insert( pieces, '[[Category:公共轉換組模板|' .. name .. ']][[Category:公共转换组模块|' .. name .. ']]' )
return table.concat( pieces )
end
-- Sunny00217 2020年1月7日 (二) 13:42 (UTC)
- 為什麼要這樣修改?這樣做有什麼好處?有什麼壞處?--Temp3600(留言) 2020年2月12日 (三) 17:51 (UTC)
- 兩個
- 加入-{H|zh-hans:模块;zh-hant:模組}-強制轉換
- 強制插入分類Category:公共转换组模块
- -- Sunny00217 2020年2月24日 (一) 14:07 (UTC)
- 這樣做有什麼好處?有什麼壞處?有那些人和事會受到影響?--Temp3600(留言) 2020年4月21日 (二) 17:14 (UTC)
- 兩個