本站页面(多半)转载自萌娘百科的同名页面,依CC BY-NC-SA 3.0引入,贡献者可以在历史页查询。
因各种原因页面内容可能和源页面有所出入,非本站特有页面内容请以萌娘百科为准。
因各种原因页面内容可能和源页面有所出入,非本站特有页面内容请以萌娘百科为准。
- 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
- 本镜像站和其他萌娘百科的镜像站无关,请注意分别。
Module:交叉颜色
跳到导航
跳到搜索
--协力:User:サンムル local p = {} function p._main(args,toggle) local texts = {} local colors = {} for k, v in pairs(args) do if type(k) == 'string' then --如果是字符串则匹配c开头 local index = k:match "^c(%d+)$" if index then colors[tonumber(index)] = v end else --是数字 texts[k] = v end end colors[0] = colors[#colors] -- 余数等于0时输出除数域 --渲染部分 local root = mw.html.create 'span' for i, v in ipairs(texts) do root:tag 'span' :wikitext(v) :css {color = colors[i%#colors], ["data-color"] = toggle and color} :addClass(toggle and 'colorToggleBlock') end return root end function p.main ( frame ) local wrappers = { ['Template:交叉颜色'] = true, ['Template:交叉颜色护眼版'] = true } local toggle = frame.args["toggle"] local parent = frame:getParent() if parent and wrappers[parent:getTitle()] then frame = parent end local args = frame.args return p._main(args,toggle) end return p