Module:Reply to
Appearance
From mediawiki.org
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
Implements {{reply to}}.
Module Quality
[edit ] Module:Reply to
success: 20, error: 0, skipped: 0
- See test cases
Usage
[edit ]{{#invoke:Reply to|replyTo}}
The above documentation is transcluded from Module:Reply to/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (edit) pages.
Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (edit) pages.
Subpages of this module.
localp={} require("strict") local_format=require("Module:TNT").format localfunctionformat(msg,...) return_format('I18n/reply.tab',msg,...) end localTEMPLATE_LINK=mw.text.tag( 'span', { class='monospaced nowrap', style='font-family:monospace,monospace;white-space:nowrap' }, mw.text.nowiki('{{') ..'[[Template:reply to|reply to]]' ..mw.text.nowiki('}}') ) localfunctionmakeError(msg,...) returnmw.text.tag( 'strong', {class='error'}, format('error',TEMPLATE_LINK,format(msg,...)) ) end functionp.replyto(frame) localorigArgs=frame:getParent().args localargs={} localmaxArg=1 localusernames=0 fork,vinpairs(origArgs)do iftype(k)=='number'then ifmw.ustring.match(v,'%S')then ifk>maxArgthenmaxArg=kend usernames=usernames+1 localtitle=mw.title.new(v) ifnottitlethenreturnmakeError('error-forbidden-input')end args[k]=title.rootText end elseifv==''andk:sub(0,5)=='label'then args[k]='​' else args[k]=v end end ifusernames>(tonumber(frame.args.max)or50)then returnmakeError('error-too-many-params',(frame.args.maxor50)) else ifusernames<1then ifframe.args.examplethenargs[1]=frame.args.exampleelsereturnmakeError('error-no-username')end end args['label1']=args['label1']orargs['label'] localisFirst=true localoutStr=args['prefix']or'@' localmsgComma=mw.message.new('comma-separator'):plain() localmsgAnd=mw.message.new('and'):plain() localmsgSpace=mw.message.new('word-separator'):plain() localmsgColon=mw.message.new('colon-separator'):plain() fori=1,maxArgdo ifargs[i]then ifisFirstthen isFirst=false else if( (usernames>2) or((usernames==2)and(args['c']=='')) )then outStr=outStr..msgComma end if((i==maxArg)and(args['c']~=''))then outStr=outStr ..(args['c'] and(msgSpace..args['c']) ormsgAnd) ..msgSpace end end outStr=string.format( '%s[[User:%s|%s]]', outStr, args[i], args['label'..tostring(i)]orargs[i] ) end end outStr=outStr..(args['p']ormsgColon) returnmw.text.tag( 'span', {class='template-ping'}, outStr ) end end returnp