Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Neighbors
Esassani
Mobai
Glenn
Mors
Creatures
Fish
Insects
Shore-Dwellers
Search
Search
English
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Item List
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
Special pages
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!
local p = {} local lib = require('Module:Feature') local Item = require('Module:Item')._main function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { parentFirst = true, removeBlanks = false, wrapper = { 'Template:Item List' } }) return p._main(args) end function p.splitNote(entry, notePattern) if notePattern then item, note = entry:match(notePattern) if item == nil then -- will be nil if note is not present return entry end return item, note end return entry end function p.splitParams(entry, paramDelim) if entry:find('{.-[^}]}') then local params = string.match(entry, '{(.-[^}])}') entry = entry:gsub('{.-[^}]}', '') params = lib.split(params, paramDelim) local returns = {} for i, param in ipairs(params) do local name, val = string.match(param, '^%s*(.-)%s*=%s*(.-)%s*$') if name ~= nil and name ~= '' and val ~= nil then --named params returns[name] = val elseif param ~= nil and param ~= '' then --unnamed params table.insert(returns, param) end end return entry, returns end return entry, {} end -- all the non-boolean params except note_delim local PARAMS_NOT_SUPPORTING_BLANKS = {"caption", "text", "amount", "delim", "amount_delim", "type", "size"} function p._main(args) local input = args[1] or '' local mode = args.mode or 'bullet' local itemDelim = args.delim or ';' local countDelim = args.amount_delim or '*' local noteDelim = args.note_delim or '/' local paramDelim = args.param_delim or '$' --= handle blanks for non-boolean params for _, paramName in ipairs(PARAMS_NOT_SUPPORTING_BLANKS) do local value = args[paramName] if value == "" then args[paramName] = nil end end -- put all text after the first noteDelim into the second capture local notePattern if lib.isNotEmpty(noteDelim) then notePattern = "^(.-)" .. noteDelim .. "(.*)$" end local result = mw.html.create() local categories = mw.html.create() local items = {} for i, entry in ipairs(lib.split(input, itemDelim, {noTrim=true})) do if lib.isNotEmpty(entry) then local entry, itemArgs = p.splitParams(entry, paramDelim) -- check for entry-specific params local item, note = p.splitNote(entry, notePattern) -- check for entry-specific note local item_parts = lib.split(item, countDelim) -- check for entry-specific amount local name = item_parts[1] local amount = item_parts[2] itemArgs.name = itemArgs[1] or itemArgs.name or name itemArgs.size = itemArgs[2] or itemArgs.size or args[2] or args.size or '20' itemArgs.count = amount or itemArgs.x or itemArgs.amount or args.x or args.amount itemArgs.type = itemArgs.type or args.type itemArgs.text = itemArgs.text or args.text itemArgs.link = itemArgs.link or args.link itemArgs.note = itemArgs.note or args.note itemArgs.ref = itemArgs.ref or args.ref itemArgs.blueprint = itemArgs.blueprint or args.blueprint itemArgs.newline = itemArgs.newline or args.newline itemArgs.notext = itemArgs.notext or args.notext itemArgs.white = itemArgs.white or args.white -- mw.logObject(itemArgs) table.insert(items, Item(itemArgs)) if (args.category ~= nil) then categories:wikitext('[[Category:', args.category:gsub('{item}', name), ']]') end end end if #items>0 then if mode == 'bullet' then local ul = result:tag('ul') for ord, item in ipairs(items) do ul:tag('li'):node(item) end elseif mode == 'br' then for ord, item in ipairs(items) do if ord ~= 1 then result:tag('br') end result:node(item) end elseif mode == 'sent' then for ord, item in ipairs(items) do if ord == 1 then elseif ord == #items then result:wikitext(#items == 2 and ' ' or ', ', 'and ') else result:wikitext(', ') end result:node(item) end else error('Invalid list format specified. Please revise [[Template:Item List]].') end if (args.category ~= nil) then result:node(require('Module:Namespace detect')._main({ main = categories })) end end return result end return p
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Petit Planet: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
—
,
­
Template used on this page:
Module:Item List/doc
(
edit
)