fbpx
วิกิพีเดีย

มอดูล:Demo

คู่มือการใช้งานมอดูล[สร้าง]
local p = {}  --creates a frame object that cannot access any of the parent's args --unless a table containing a list keys of not to inherit is provided function disinherit(frame, onlyTheseKeys)  local parent = frame:getParent() or frame  local orphan = parent:newChild{}  orphan.getParent = parent.getParent --returns nil  orphan.args = {}  if onlyTheseKeys then  local family = {parent, frame}  for f = 1, 2 do  for k, v in pairs(family[f] and family[f].args or {}) do  orphan.args[k] = orphan.args[k] or v  end  end  parent.args = mw.clone(orphan.args)  setmetatable(orphan.args, nil)  for _, k in ipairs(onlyTheseKeys) do  rawset(orphan.args, k, nil)  end  end  return orphan, parent end  function p.get(frame, arg, passArgs)  local orphan, frame = disinherit(frame, passArgs and {arg or 1})  local code, noWiki, preserve = frame.args[arg or 1] or ''  if code:match'nowiki' then  local placeholder, preserve = ('6'):char(), {}  code = mw.text.unstripNoWiki(code)  noWiki = code:gsub('%%', placeholder):gsub('&lt;', '<'):gsub('&gt;', '>')  for k in noWiki:gmatch('&.-;') do  if not preserve[k] then  preserve[k] = true  table.insert(preserve, (k:gsub('&', '&amp;')))  noWiki = noWiki:gsub('(&.-;)', '%%%s')  end  end  noWiki = mw.text.nowiki(noWiki):format(unpack(preserve)):gsub(placeholder, '%%')  end  local kill_categories = frame.args.demo_kill_categories or frame.args.nocat  return {  source = noWiki or code,  output = orphan:preprocess(code):gsub(kill_categories and '%[%[Category.-%]%]' or '', ''),  frame = frame  } end  function p.main(frame, demoTable)  local show = demoTable or p.get(frame)  local args = show.frame.args  args.br = tonumber(args.br or 1) and ('<br>'):rep(args.br or 1) or args.br or ''  if show[args.result_arg] then  return show[args.result_arg]  end  return string.format('<pre%s>%s</pre>%s%s', args.style and string.format(" style='%s'", args.style) or '', show.source, args.br, show.output) end  -- Alternate function to return an inline result function p.inline(frame, demoTable)  local show = demoTable or p.get(frame)  local args = show.frame.args  if show[args.result_arg] then  return show[args.result_arg]  end  return string.format('<code%s>%s</code>%s%s', args.style and string.format(" style='%s'", args.style) or '', show.source, ' → ', show.output) end  --passing of args into other module without preprocessing function p.module(frame)  local orphan, frame = disinherit(frame, {  'demo_template',  'demo_module',  'demo_module_func',  'demo_main',  'demo_br',  'demo_result_arg',  'demo_kill_categories',  'nocat'  })  local template = frame.args.demo_template and 'Template:'..frame.args.demo_template  local demoFunc = frame.args.demo_module_func or 'main\n'  local demoModule = require('Module:' .. frame.args.demo_module)[demoFunc:match('^%s*(.-)%s*$')]  frame.args.br, frame.args.result_arg = frame.args.demo_br, frame.args.demo_result_arg  local kill_categories = frame.args.demo_kill_categories or frame.args.nocat  if demoModule then  local named = {insert = function(self, ...) table.insert(self, ...) return self end}  local source = {insert = named.insert, '{{', frame.args.demo_template or frame.args.demo_module, '\n'}  if not template then  source:insert(2, '#invoke:'):insert(4, '|'):insert(5, demoFunc)  end  local insertNamed = #source + 1  for k, v in pairs(orphan.args) do  local nan, insert = type(k) ~= 'number', {v}  local target = nan and named or source  target:insert'|'  if nan then  target:insert(k):insert'=':insert'\n'  table.insert(insert, 1, #target)  end  target:insert(unpack(insert))  local nowiki = v:match('nowiki')  if nowiki or v:match('{{.-}}') then  orphan.args[k] = frame:preprocess(nowiki and mw.text.unstripNoWiki(v) or v)  end  end  source:insert'}}'  table.insert(source, insertNamed, table.concat(named))  return p.main(orphan, {  source = mw.text.encode(table.concat(source), "<>'|=~"),  output = tostring(demoModule(orphan)):gsub(kill_categories and '%[%[Category.-%]%]' or '', ''),  frame = frame  })  else  return "ERROR: Invalid module function: "..demoFunc  end end  return p 

มอด, demo, อการใช, งานมอด, สร, าง, ณอาจจะต, องการสร, างค, อการใช, งานของมอด, ลน, เข, ยนสามารถทำการทดลองได, กระบะทราย, สร, าง, ดลอก, และช, ดทดสอบ, สร, าง, ของมอด, ลน, โปรดเพ, มหมวดหม, ไปท, หน, าย, อย, หน, าย, อยของมอด, ลน, local, creates, frame, object, that, c. khumuxkarichnganmxdul srang khunxaccatxngkarsrangkhumuxkarichngankhxngmxdulniphuekhiynsamarththakarthdlxngidthikrabathray srang khdlxk aelachudthdsxb srang khxngmxdulnioprdephimhmwdhmuipthihnayxy doc hnayxykhxngmxdulnilocal p creates a frame object that cannot access any of the parent s args unless a table containing a list keys of not to inherit is provided function disinherit frame onlyTheseKeys local parent frame getParent or frame local orphan parent newChild orphan getParent parent getParent returns nil orphan args if onlyTheseKeys then local family parent frame for f 1 2 do for k v in pairs family f and family f args or do orphan args k orphan args k or v end end parent args mw clone orphan args setmetatable orphan args nil for k in ipairs onlyTheseKeys do rawset orphan args k nil end end return orphan parent end function p get frame arg passArgs local orphan frame disinherit frame passArgs and arg or 1 local code noWiki preserve frame args arg or 1 or if code match nowiki then local placeholder preserve 6 char code mw text unstripNoWiki code noWiki code gsub placeholder gsub amp lt lt gsub amp gt gt for k in noWiki gmatch amp do if not preserve k then preserve k true table insert preserve k gsub amp amp amp noWiki noWiki gsub amp s end end noWiki mw text nowiki noWiki format unpack preserve gsub placeholder end local kill categories frame args demo kill categories or frame args nocat return source noWiki or code output orphan preprocess code gsub kill categories and Category or frame frame end function p main frame demoTable local show demoTable or p get frame local args show frame args args br tonumber args br or 1 and lt br gt rep args br or 1 or args br or if show args result arg then return show args result arg end return string format lt pre s gt s lt pre gt s s args style and string format style s args style or show source args br show output end Alternate function to return an inline result function p inline frame demoTable local show demoTable or p get frame local args show frame args if show args result arg then return show args result arg end return string format lt code s gt s lt code gt s s args style and string format style s args style or show source show output end passing of args into other module without preprocessing function p module frame local orphan frame disinherit frame demo template demo module demo module func demo main demo br demo result arg demo kill categories nocat local template frame args demo template and Template frame args demo template local demoFunc frame args demo module func or main n local demoModule require Module frame args demo module demoFunc match s s frame args br frame args result arg frame args demo br frame args demo result arg local kill categories frame args demo kill categories or frame args nocat if demoModule then local named insert function self table insert self return self end local source insert named insert frame args demo template or frame args demo module n if not template then source insert 2 invoke insert 4 insert 5 demoFunc end local insertNamed source 1 for k v in pairs orphan args do local nan insert type k number v local target nan and named or source target insert if nan then target insert k insert insert n table insert insert 1 target end target insert unpack insert local nowiki v match nowiki if nowiki or v match then orphan args k frame preprocess nowiki and mw text unstripNoWiki v or v end end source insert table insert source insertNamed table concat named return p main orphan source mw text encode table concat source lt gt output tostring demoModule orphan gsub kill categories and Category or frame frame else return ERROR Invalid module function demoFunc end end return p ekhathungcak https th wikipedia org w index php title mxdul Demo amp oldid 9219937, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม