asbox Stubtree

Documentation for this module may be created at Module:Asbox stubtree/doc

local i = {}  function i.exists(pagename)     local t = mw.title.new(pagename, "Template")     return t.exists end  function i.pcase(word)    return mw.ustring.upper(mw.ustring.sub(word,1,1)) .. mw.ustring.sub(word,2) end  function i._subtree(pagename)     local finalresult     local out = {"",pagename}     local tt     local temppage     local temppageexists     local r = 0     local t = {}     local removeditem1 = ""     local removeditem2 = ""          -- split items on dash into table     for token in mw.ustring.gmatch(pagename, "[^-]+") do         -- don't add numbered items to list         if tonumber(mw.ustring.sub(token,1,1)) == nil then             table.insert(t,token)         else             r = 1         end     end     table.remove(t, #t)      while (#t > 1) do         if r == 1 then             r = 0         else             -- Remove 1st item from list             removeditem1 = t[1]             table.remove(t, 1)         end          temppage = table.concat(t, "-") .. "-stub"         temppageexists = i.exists(temppage)         if temppageexists == true then             table.insert(out,"[[Template:" .. temppage .. "|" .. i.pcase(temppage) .. "]]")         else             -- If template with first item does not exist, try removing last item             removeditem2 = t[#t]             table.remove(t, #t)             temppage = removeditem1 .. "-" .. table.concat(t, "-") .. "-stub"             if #t == 0 then                 temppage = removeditem1 .. "-stub"             end             temppageexists = i.exists(temppage)             if temppageexists == true then                 -- if exists then add first item back to list                 table.insert(t,1,removeditem1)                 table.insert(out,"[[Template:" .. temppage .. "|" .. i.pcase(temppage) .. "]]")             else                 -- if exists then add last item back to list                 table.insert(t,removeditem2)             end         end     end      finalresult = '
' finalresult = finalresult .. 'Stub hierarchy' finalresult = finalresult .. table.concat(out, "\n* ") finalresult = finalresult .. '\n* [[Plantilya:Saha|Saha]]' finalresult = finalresult .. '\n
'
return finalresult end function i.subtree(frame) return i._subtree(frame.args["pagename"]) end return i

Tags:

🔥 Trending searches on Wiki Sinugboanong Binisaya:

Digital object identifierPransiyaAkto Sa PaghinulsolGwen GarciaMqinvari NamqvamiPassiflora caeruleaDildoBotolan, ZambalesKadagatang PasipikoPantabangan DamLeon KilatWhakeJose Panganiban, Camarines NorteSoccsksargenAnimasyonBoholDinalupihanMacaca cyclopisPakighilawasRiacho SecoBeauty BayApache CountyOmanTalim IslandManitobaEusparassus walckenaeri2015Cruciata laevipesSiquijor IslandMakar RiverTimbunganHiligaynonDankowiceJuan LargoDakbayan sa SugboCentral Hidroeléctrica HuincoLargs Peak (tumoy sa bukid)BarilisEnsiklopedyaMq'invari Ach'apara (suba sa yelo sa Geyorgya, lat 43,13, long 42,10)Tabang RiverGynandropsis gynandraPuloCercis griffithiiLalawigan Point (punta sa Pilipinas, Sidlakang Kabisay-an)Lubenka (lungsod sa Polskowa)State of Andhra PradeshMaghimaya Ka MariaJlijNaked BoyMount BitaMga adlaw sa semanaUbay, BoholNeale RiverPangasinanGobolka BariOktubre 22Equus quaggaIndonesiaWenceslao Selga PadillaTaka Shima (kapuloan)🡆 More