Difference between revisions of "Module:ListParserTooltip"

From Dragalia Lost Wiki
Jump to navigation Jump to search
>Caledor92
(Created page with "-- <includeonly> (prevents literal interpretation of links or categories within the module code) -- Lua Templating for {{SummonShowcase}}, {{Event}} and any other templates re...")
>Eave
m (removing redundant linkify method, and updating inline documentation to reflect how to call this)
 
Line 5: Line 5:
 
local itemTemplate = '<div style="display:inline-block;vertical-align:top;width:80px;text-align:center;padding:4px">%s</div>'
 
local itemTemplate = '<div style="display:inline-block;vertical-align:top;width:80px;text-align:center;padding:4px">%s</div>'
  
 
+
-- Usage: {{#invoke:ListParserTooltip|Adventurers|<names,comma,separated>}}
-- Usage: {{#invoke:ListParser|Linkify|<page names,comma,separated>}}
+
-- Ex: {{#invoke:ListParserTooltip|Adventurers|Halloween Mym, Halloween Lowen, Halloween Odetta, Halloween Elisanne}}
-- Ex: {{#invoke:ListParser|Linkify|Wyrmite, Elisanne, Dragalia Life}}
 
function p.Linkify(frame)
 
  local pages = frame.args[1]
 
  return p._linkify(pages)
 
end
 
 
 
function p._linkify(pages)
 
  local result = {}
 
 
 
  for pagename in mw.text.gsplit(pages, ',') do
 
    pagename = mw.text.trim(pagename)
 
    if pagename ~= '' then
 
      result[#result+1] = string.format('[[%s]]', pagename)
 
    end
 
  end
 
 
 
  return table.concat(result, ', ')
 
end
 
 
 
-- Usage: {{#invoke:ListParser|Adventurers|<names,comma,separated>}}
 
-- Ex: {{#invoke:ListParser|Adventurers|Halloween Mym, Halloween Lowen, Halloween Odetta, Halloween Elisanne}}
 
 
function p.Adventurers(frame)
 
function p.Adventurers(frame)
 
   local names = frame.args[1]
 
   local names = frame.args[1]
Line 46: Line 25:
 
end
 
end
  
-- Usage: {{#invoke:ListParser|Dragons|<names,comma,separated>}}
+
-- Usage: {{#invoke:ListParserTooltip|Dragons|<names,comma,separated>}}
-- Ex: {{#invoke:ListParser|Dragons|Halloween Maritimus, Halloween Silke}}
+
-- Ex: {{#invoke:ListParserTooltip|Dragons|Halloween Maritimus, Halloween Silke}}
 
function p.Dragons(frame)
 
function p.Dragons(frame)
 
   local names = frame.args[1]
 
   local names = frame.args[1]
Line 66: Line 45:
 
end
 
end
  
-- Usage: {{#invoke:ListParser|Wyrmprints|<names,comma,separated>}}
+
-- Usage: {{#invoke:ListParserTooltip|Wyrmprints|<names,comma,separated>}}
-- Ex: {{#invoke:ListParser|Wyrmprints|Witch's Kitchen}}
+
-- Ex: {{#invoke:ListParserTooltip|Wyrmprints|Witch's Kitchen}}
 
function p.Wyrmprints(frame)
 
function p.Wyrmprints(frame)
 
   local names = frame.args[1]
 
   local names = frame.args[1]
Line 86: Line 65:
 
end
 
end
  
-- Usage: {{#invoke:ListParser|Weapons|<names,comma,separated>}}
+
-- Usage: {{#invoke:ListParserTooltip|Weapons|<names,comma,separated>}}
-- Ex: {{#invoke:ListParser|Weapons|Fólkvangr}}
+
-- Ex: {{#invoke:ListParserTooltip|Weapons|Fólkvangr}}
 
function p.Weapons(frame)
 
function p.Weapons(frame)
 
   local names = frame.args[1]
 
   local names = frame.args[1]

Latest revision as of 01:06, 22 July 2020

50px Documentation

Also see Module:ListParser.

{{#invoke:ListParserTooltip|Weapons|Rathalos Firesword, Wyvern Blade “Maple”, Blazing Falchion, Rath Blaze Splitter, Spear of Prominence, Dark Filament, Plage Rod, Wyvern Staff “Elsewhere”, Fatalis Sword, Fatalis Xiphos, Black Dragon Blade, Black Dragon Axe, Black Dragon Spear, Black Dragon Bow, Fatalis Rhabdos, Black Dragon Staff}}
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.
Unknown.png
Error: Table Weapons not found.

-- <includeonly> (prevents literal interpretation of links or categories within the module code)
-- Lua Templating for {{SummonShowcase}}, {{Event}} and any other templates requiring items to be listed in a series (,).
local p = {}

local itemTemplate = '<div style="display:inline-block;vertical-align:top;width:80px;text-align:center;padding:4px">%s</div>'

-- Usage: {{#invoke:ListParserTooltip|Adventurers|<names,comma,separated>}}
-- Ex: {{#invoke:ListParserTooltip|Adventurers|Halloween Mym, Halloween Lowen, Halloween Odetta, Halloween Elisanne}}
function p.Adventurers(frame)
  local names = frame.args[1]
  return p._Adventurers(names)
end

function p._Adventurers(names)
  local result = {}

  for name in mw.text.gsplit(names, ',') do
    name = mw.text.trim(name)
    if name ~= '' then
      result[#result+1] = string.format(itemTemplate, icon('Adventurer', name), name)
    end
  end

  return table.concat(result, '')
end

-- Usage: {{#invoke:ListParserTooltip|Dragons|<names,comma,separated>}}
-- Ex: {{#invoke:ListParserTooltip|Dragons|Halloween Maritimus, Halloween Silke}}
function p.Dragons(frame)
  local names = frame.args[1]
  return p._Dragons(names)
end

function p._Dragons(names)
  local result = {}

  for name in mw.text.gsplit(names, ',') do
    name = mw.text.trim(name)
    if name ~= '' then
      result[#result+1] = string.format(itemTemplate, icon('Dragon', name), name)
    end
  end

  return table.concat(result, '')
end

-- Usage: {{#invoke:ListParserTooltip|Wyrmprints|<names,comma,separated>}}
-- Ex: {{#invoke:ListParserTooltip|Wyrmprints|Witch's Kitchen}}
function p.Wyrmprints(frame)
  local names = frame.args[1]
  return p._Wyrmprints(names)
end

function p._Wyrmprints(names)
  local result = {}

  for name in mw.text.gsplit(names, ',') do
    name = mw.text.trim(name)
    if name ~= '' then
      result[#result+1] = string.format(itemTemplate, icon('Wyrmprint', name), name)
    end
  end

  return table.concat(result, '')
end

-- Usage: {{#invoke:ListParserTooltip|Weapons|<names,comma,separated>}}
-- Ex: {{#invoke:ListParserTooltip|Weapons|Fólkvangr}}
function p.Weapons(frame)
  local names = frame.args[1]
  return p._Weapons(names)
end

function p._Weapons(names)
  local result = {}

  for name in mw.text.gsplit(names, ',') do
    name = mw.text.trim(name)
    if name ~= '' then
      result[#result+1] = string.format(itemTemplate, icon('Weapon', name), name)
    end
  end

  return table.concat(result, '')
end


-- Common templating functions

-- {{Icon}}
function icon(type, name)
  local frame = mw.getCurrentFrame()
  return frame:expandTemplate{title='TooltipIcon', args={type, name, text=1}}
end

return p
--</includeonly>