Module:Sandbox/BrownHairedGirl/IrelandByCountyCatNav explained

local p =

function make_cat_link(catname, disp) local displaytext if (disp ~= "") then displaytext = disp else displaytext = catname end local link = "" .. displaytext .. "" local fmtlink local linktitle = mw.title.new(catname, "Category") if (linktitle.exists) then fmtlink = link else fmtlink = "

" .. displaytext .. "" end

return fmtlinkendlocal p =

function boolify(s) if (s

nil or s

) then return false end s = s:lower if (s

'y' or s

'yes') then return true end return falseend

function make_cat_name(countyname, prefix, suffix, nospace, nocounty) local this_cat_name = ; if not (prefix

nil or prefix

) then this_cat_name = this_cat_name .. prefix if not (boolify(nospace)) then this_cat_name = this_cat_name .. ' '; end end if not (boolify(nocounty)) then this_cat_name = this_cat_name .. 'County '; end this_cat_name = this_cat_name .. countyname if not (suffix

nil or suffix

) then if not (boolify(nospace)) then this_cat_name = this_cat_name .. ' '; end this_cat_name = this_cat_name .. suffix end return this_cat_nameend

-- Named arguments, used like: function p.main(frame) local p_before = frame.args.before local p_after = frame.args.after local p_nospace = frame.args.nospace local p_nocounty = frame.args.nocounty local retval = ""; retval = retval .. "

"
	retval = retval .. '\nbefore=[' .. p_before .. ']' .. '\nafter=[' .. p_after .. ']' .. '\nnospace=[' .. p_nospace .. ']' .. '\nnocounty=[' .. p_nocounty .. ']' 
	retval = retval .. "
" retval = retval .. "\n\n-->\n\n* Cat = [" .. make_cat_name("Mayo", p_before, p_after, p_nospace, p_nocounty) .. "]\n" retval = retval .. "* Catlink = " .. make_cat_link(make_cat_name("Mayo", p_before, p_after, p_nospace, p_nocounty), "Mayo") local thispage = mw.title.getCurrentTitle local pagename = thispage.text retval = retval .. "\n* thispage" retval = retval .. "\n**pagename = [" .. pagename .."]" retval = retval .. "\n**namespace = [" .. thispage.namespace .."]" retval = retval .. "\n**namespace as text = [" .. thispage.nsText .."]" retval = retval .. "\n**is it a cat? = " if (thispage:inNamespace(14)) then retval = retval .. "yes" else retval = retval .. "no" end return retvalend

return p