Module:沙盒/盐棋/Sandbox1:修订间差异

来自Arcaea中文维基
(wrap)
(try)
标签替换
 
(未显示同一用户的18个中间版本)
第1行: 第1行:
local p = {}
local p = {}
p.filter = { text = mw.text.encode, json = mw.text.jsonEncode, no = function(x) return x end }
function p.len(frame)
function p.label_text(text)
return #frame.args.a
return tostring(mw.html.create('span'):addClass('label-text'):wikitext(text))
end
end
function p.tab_img(id, config)
function p.explode(frame)
local container = mw.html.create('div'):addClass('container')
return mw.dumpObject({mw.ustring.byte(frame.args.a,1,-1)})
if #config == 1 then
container:wikitext(config[1].content)
else
local img_tab, tab_text = container:tag('div'):addClass('img-tab'), {}
for _, tab in ipairs(config) do
img_tab:tag('div'):addClass('img-tab-part'):addClass(tab.class):wikitext(tab.tab)
table.insert(tab_text, container:tag('div'):addClass('tab-text-a'):wikitext(tab.content))
end
tab_text[id]:addClass('active')
end
return tostring(container)
-- return '[[文件:Songs '..tostring(id) .. '.jpg|点此上传图片]]'
end
function p.wrap(frame)
return mw.text.jsonEncode(frame.args, mw.text.JSON_PRESERVE_KEYS)
end
function p.file_song(id, suf, illust)
return string.format('[[文件:Songs %s%s.jpg|256px|none]]%s%s', id, suf, p.label_text('画师'), illust)
end
function p.song(frame)
local config, main = {}, 1
for i, v in ipairs(frame.args) do
local item = mw.text.jsonDecode(v) -- use json. what about use in module
local suf = item['后缀'] and ' ' .. item['后缀'] or ''
table.insert(config, {
class = item['色彩'],
tab = item['标签'],
content = p.file_song(frame.args['id'], suf, item['画师']),
})
if suf == '' then main = i end
end
return p.tab_img(main, config)
end
function p.direct(frame)
return p.filter[frame.args[3] or 'no'](p.tab_img(frame.args[1], frame.args[2]))
end
function p.jsonmode(frame)
return p.filter[frame.args[3] or 'no'](p.tab_img(frame.args[1], mw.text.jsonDecode(frame.args[2])))
end
end
return p
return p

2024年2月27日 (二) 03:17的最新版本

可在Module:沙盒/盐棋/Sandbox1/doc创建此模块的帮助文档

local p = {}
function p.len(frame)
	return #frame.args.a
end
function p.explode(frame)
	return mw.dumpObject({mw.ustring.byte(frame.args.a,1,-1)})
end
return p