Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Special pages
Random page
Wiki Discord
Contents
Neighbors
Galaxy
> Hexia
> Norvan
> Pashah
> Taffeh
Creatures
> Insects
> Fishes
> Shore-Dwellers
Items
> Dishes
> Furniture
Game Systems
> Dress Up
> Luca Arbor
> Loomix Footprints
> Loomix Vehicle Services
> Loomix Homes
Search
Search
Appearance
Log in
Personal tools
Log in
Editing
Module
:
Loops
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- Imported from: https://dev.miraheze.org/wiki/Module:Loops local p = {}; local getArgs = require("Module:Arguments").getArgs; -- Note to dev wiki editors: this function is copied from Module:Example. -- Changes to this function should be synced with the source. local function unescape(text) if not text:match("UNIQ") then return text; end local unescaped = mw.text.unstripNoWiki(text); local text, count = string.gsub(unescaped, "<", "<"); text, count = string.gsub(text, ">", ">"); text, count = string.gsub(text, "<//nowiki>", "</nowiki>"); return text; end -- This feature is experimental and therefore undocumented. local function sentenceJoin(lst, delimiter, beforeLast) if not delimiter then delimiter = ", "; if not beforeLast then beforeLast = "and"; end elseif not beforeLast then beforeLast = delimiter; end local count = #lst; if count == 0 then return ""; elseif count == 1 then return lst[1]; elseif count == 2 then return string.format("%s %s %s", lst[1], beforeLast, lst[2]); else local last = lst[count]; lst[count] = nil; return string.format("%s %s %s", table.concat(lst, delimiter), beforeLast, last ); end end -- This feature is experimental and therefore undocumented. function formatConcat(result, args) local outputFormat = args['format'] or nil; if not outputFormat then return table.concat(result, ""); end if outputFormat == "concat" then return sentenceJoin(result, args['delimiter'], args['final-delimiter']); end end function p.loop(frame) local args = getArgs(frame); local variableName = args[1]; local startingValue = tonumber(args[2]) or 1; local loopNum = tonumber(args[3]) or 0; local markup = unescape(args[4]); local result = {}; for i = startingValue, startingValue + loopNum - 1 do local s = markup:gsub(variableName, tostring(i)); table.insert(result, s); end return frame:getParent():preprocess(formatConcat(result, args)); end function p.fornumargs(frame) local args = getArgs(frame, { removeBlanks = false }); local keyName = args['key'] or "DNE"; local valueName = args['value'] or "DNE"; local markup = unescape(args['pattern']); local keys = {}; for k, v in pairs(args) do if type(k) == "number" then table.insert(keys, k); end end table.sort(keys); local result = {}; for _, key in ipairs(keys) do local value = args[key]; local s = markup:gsub(keyName, key):gsub(valueName, value); table.insert(result, s); end return frame:getParent():preprocess(formatConcat(result, args)); end function p.forargs(frame) local args = getArgs(frame, { removeBlanks = false }); local prefix = args[1] or ""; local keyName = args[2] or "DNE"; local valueName = args[3] or "DNE"; local markup = unescape(args[4]); for i = 1, 4 do table.remove(args, i); end local keys = {}; for k, v in pairs(args) do if type(k) == "string" then i, j = k:find(prefix); if i ~= nil and i == 1 then table.insert(keys, k:sub(j + 1)); end end end table.sort(keys); local result = {}; for _, key in ipairs(keys) do local value = args[prefix .. key]; local s = markup:gsub(keyName, key):gsub(valueName, value); table.insert(result, s); end return frame:getParent():preprocess(formatConcat(result, args)); end return p;
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Petit Planet Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Pages included on this page:
Template:Documentation/Header
(
edit
)
Template:Documentation/styles.css
(
edit
)
Template:F
(
edit
)
Template:M
(
edit
)
Template:TOC Right
(
edit
)
Module:Arguments
(
edit
)
Module:Arguments/i18n
(
edit
)
Module:Common/i18n
(
edit
)
Module:Config
(
edit
)
Module:Documentation
(
edit
)
Module:Documentation/config
(
edit
)
Module:Documentation/i18n
(
edit
)
Module:Entrypoint
(
edit
)
Module:Exists
(
edit
)
Module:Fallbacklist
(
edit
)
Module:Feature
(
edit
)
Module:Formatting
(
edit
)
Module:I18n
(
edit
)
Module:Languages
(
edit
)
Module:Loops/doc
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
This page is a member of 2 hidden categories:
Category:Pages using DynamicPageList4 parser function
Category:Pages using DynamicPageList4
Search
Search
Editing
Module
:
Loops
Add topic