Modul:Country listdata

Iz Wikipedije, proste enciklopedije
Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osveži]

This template formats a list of country data templates, for use as "see also" in the documentation of such templates.

Parameters[uredi kodo]

1, 2, ..., n
Each numbered parameter is a country, subdivision or other entity name, corresponding to what you would use as first parameter in flag templates such as {{flag}}.
var1, var2, ..., varn
Specify flag variants for the corresponding entities. The variant name is displayed in brackets.
note1, note2, ..., noten
Add explanatory text to the right of each row.
header
Inserts a standardized text above the list. Possible values are "related", "for:" followed by any text, or anything else for custom text.

Examples[uredi kodo]

{{country listdata|Afganistan|Albanija|Alžirija}}

 Afganistan
 Albanija
 Alžirija

Using variants and notes:

{{country listdata|Avstralija|var1=naval|Brazilija|note2=This is a note}}

 Avstralija
 BrazilijaThis is a note

In the parameter list, parameters with empty strings or whitespace only are allowed and not included in the output, so parameters can be safely emptied to remove a country. Undefined "gaps", however, such as parameter 6 in this example, will cause all higher-number parameters to be ignored.

{{country listdata|1=Afganistan|2=Albanija|3= |4=AAlžirijageria|5=Andora|7=Angola|8=Italija}}

 Afganistan
 Albanija
 Alžirija
 Andora
local p = {}

function p.main(frame)

local args = require('Modul:Arguments').getArgs(frame,{removeBlanks=false})

local list = ""
if args[1] then
  list = mw.html.create('table')
  list:css("background-color","#ecfcf4")
  for n,c in ipairs(args) do
    if c~="" then
      local title = mw.title.new("Predloga:Podatki države "..c)
      local link
      if title.isRedirect then
        link = "["..title:fullUrl("redirect=no").." "..title.fullText.."]"
      else
        link = "[["..title.fullText.."]]"
      end
      local var = args["var"..n] or ""
      local vartext = var=="" and "" or " (<code>"..var.."</code> variant)"
      local note = args["note"..n] or ""

      local row = list:tag("tr")
      row:tag("td"):css("padding","0px 10px"):addClass("plainlinks"):wikitext(link..vartext)
      row:tag("td"):css("padding","0px 10px"):wikitext(require("Modul:Flagg").luaMain(frame,{"usc", c, variant=var}))
      row:tag("td"):css("padding","0px 10px"):wikitext(note)
    end
  end
end

local head = ""
if args["header"] and args["header"]~="" then
  if args["header"]=="related" then
    head = "====Sorodne predloge====\nProsimo, glejte sledeče sorodne predloge  <code>podatki_države</code>:"
  elseif string.sub(args["header"],1,4)=="for:" then
    head = "Predloge <code>Podatki_države</code> so na voljo tudi za "..string.sub(args["header"],5,-1)..":"
  else
    head = args["header"]
  end
end

return head..(head~="" and list~="" and "\n" or "")..tostring(list)

end

return p