 local checktype require 'libraryutil' .checktype local pu800 local body_param ' bu800' local specialparams ' params 'parameter list' ' aliases 'parameter aliases ' flags 'flags ' bu800' 'template content' function pu800u82emain frame body ifu800 weu800 areu800 substing this function returns au800 template invocation andu800 ifu800 notu800 itu800 returns theu800 template body. theu800 template body canu800 beu800 specified inu800 theu800 body parameter oru800 inu800 theu800 template parameter defined inu800 theu800 body_param variable. this function canu800 beu800 called from luau800 oru800 from #invoke. return theu800 template body ifu800 weu800 aren'tu800 substing. ifu800 notu800 mwu800u82eissubsting then ifu800 body nilu800 then return body elseif frameu82eargs body_param nilu800 then return frameu82eargs body_param else error stringu82eformat "nou800 template content specified useu800 parameter ' su800' from #invoke " body_param 2u800 endu800 endu800 sanity check foru800 theu800 frame object. ifu800 type frame 'table' oru800 type frameu82egetparent 'function' oru800 notu800 frame getparent then error "argument #1u800 tou800 'main' must beu800 au800 frame object with au800 parent " .. "frame available" 2u800 endu800 find theu800 invocation name. local mtemplateinvocation require 'module template invocation' local name mtemplateinvocationu82ename frame getparent gettitle combine passed args with passed defaults local args ifu800 stringu82efind ' '.. frameu82eargs ' flags oru800   ..' ' ' su800*override su800* ' then foru800 ku800 vu800 inu800 pairs frame getparent .args dou800 args ku800 vu800 endu800 foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 ifu800 notu800 specialparams ku800 then ifu800 vu800 '__date__' then vu800 mwu800u82egetcontentlanguage formatdate 'fu800 yu800' endu800 args ku800 vu800 endu800 endu800 else foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 ifu800 notu800 specialparams ku800 then ifu800 vu800 '__date__' then vu800 mwu800u82egetcontentlanguage formatdate 'fu800 yu800' endu800 args ku800 vu800 endu800 endu800 foru800 ku800 vu800 inu800 pairs frame getparent .args dou800 args ku800 vu800 endu800 endu800 trim parameters ifu800 notu800 specified otherwise ifu800 notu800 stringu82efind ' '.. frameu82eargs ' flags oru800   ..' ' ' su800*keep whitespace su800* ' then foru800 ku800 vu800 inu800 pairs args dou800 args ku800 mwu800u82eustringu82ematch vu800 ' su800* .* su800* ' oru800   endu800 endu800 pull information from parameter aliases local aliases ifu800 frameu82eargs ' aliases then local list mwu800u82etextu82esplit frameu82eargs ' aliases ' su800* su800*' foru800 ku800 vu800 inu800 ipairs list dou800 local tmpu800 mwu800u82etextu82esplit vu800 ' su800* su800*' aliases tonumber mwu800u82eustringu82ematch tmpu800 1u800 ' 1u800 9u800 0u800 9u800 * ' oru800 tmpu800 1u800 tonumber mwu800u82eustringu82ematch tmpu800 2u800 ' 1u800 9u800 0u800 9u800 * ' oru800 tmpu800 2u800 endu800 endu800 foru800 ku800 vu800 inu800 pairs aliases dou800 ifu800 args ku800 andu800 notu800 args vu800 oru800 args vu800   then args vu800 args ku800 endu800 args ku800 nilu800 endu800 remove empty parameters ifu800 specified ifu800 stringu82efind ' '.. frameu82eargs ' flags oru800   ..' ' ' su800*remove empty su800* ' then local tmpu800 0u800 foru800 ku800 vu800 inu800 ipairs args dou800 ifu800 vu800   oru800 args ku800 1u800 andu800 args ku800 1u800   oru800 args ku800 2u800 andu800 args ku800 2u800   then tmpu800 ku800 else break endu800 endu800 foru800 ku800 vu800 inu800 pairs args dou800 ifu800 vu800   then ifu800 notu800 type ku800 'number' andu800 ku800 tmpu800 then args ku800 nilu800 endu800 endu800 endu800 endu800 order parameters ifu800 frameu82eargs ' params then local params tmpu800 mwu800u82etextu82esplit frameu82eargs ' params ' su800* su800*' foru800 ku800 vu800 inu800 ipairs params dou800 vu800 tonumber mwu800u82eustringu82ematch vu800 ' 1u800 9u800 0u800 9u800 * ' oru800 vu800 ifu800 args vu800 then tmpu800 vu800 args vu800 args vu800 nilu800 endu800 endu800 foru800 ku800 vu800 inu800 pairs args dou800 tmpu800 ku800 args ku800 args ku800 nilu800 endu800 args tmpu800 endu800 return mtemplateinvocationu82einvocation name args endu800 pu800   pu800u82emain foru800 backwards compatibility return pu800 