帮助:Sandbox

来自Cookie☆Wiki
艾了个拉留言 | 贡献2019年1月15日 (二) 02:17的版本 (由于无法处理 <gallery>, 只得换用并不兼容原有画廊用法的方法)

local p = {}

function p.make()

   local frame = mw.getCurrentFrame()
   local parent = frame:getParent()
   local arg = parent.args['image']
   if arg != nil then --< 单张图片
       if string.byte(arg, 1) == 127 then
           return '\
           不支持<gallery>语法\'
       end
       return frame:expandTemplate{ title = 'Infobox/item/single image', args = {
           image = arg, caption = parent.args['caption']
       } }
   end
   arg = parent.args['gallery']
   if arg == nil then --< 根本没有图片
       return 
   end
   for image_line in arg:gmatch('[^\r\n]+') do
       -- table.insert(lines, line)
       local sep = image_line:find(':')
       table.insert(images, {
           file = string.sub(image_line, 1, sep-1),
           title = string.sub(image_line, sep+1, -1)
       })
   end
   return mw.dumpObject(images) --< debug

end

return p