Module:Foreach

-- Replace http://www.mediawiki.org/wiki/Template:Foreach -- Of course, this is pretty trivial in Lua, but it's also a mite nicer

-- Use: -- local lforeach = require('Module:Foreach').lforeach -- lforeach({'Whatever', 'one,two,three', ',') -- Or: --

function lforeach(frame) local tplname = frame.args[1] local items = frame.args[2].usplit(',') local delim = frame.args[3] or nil

finalstr = '' for index, item in ipairs(items) do       if index > 0 and delim then finalstr = finalstr .. delim end finalstr = finalstr .. ''   end return finalstr end

return {lforeach = lforeach}