Module:Join: Difference between revisions

From RabastorWiki
Jump to navigation Jump to search
m (1 revision imported)
 
(No difference)

Latest revision as of 06:13, 24 May 2016

--[[ Join

Joins all non null arguments together, the first argument is the separator

   Lua error: Cannot create process: proc_open(/home4/iltornan/lua/error.log): Failed to open stream: No such file or directory

/*

  • /
   if args[1] == nil then
       local pFrame = frame:getParent();
       args = pFrame.args;
       for k,v in pairs( frame.args ) do
           args[k] = v;
       end
   end

]]

local join = {}

function join.join(frame)

   local res=;
   local args = {};
   for k,v in pairs( frame.args ) do
     if v ~= nil and v ~=  then
        table.insert(args,v)
        --res = res .. '[' .. k .. ']=' ..v
     end
   end
   local sep = args[1];
   res = table.concat( args, sep, 2, j );
   return res

end

function join.join2(frame)

   local res=;
   local args = {};
   for k,v in pairs( frame.args ) do
     if v ~= nil and v ~=  then
        table.insert(args,v)
        --res = res .. '[' .. k .. ']=' ..v
     end
   end
   local sep = args[1];
   local sep2 = args[2];
   if #args < 3 then
     res = 
   elseif #args == 3 then
     res = args[3]
   elseif #args == 4 then
     res = args[3] .. sep2 .. args[4]
   else
     res = table.concat( args, sep, 3, #args-1 );
     res = res .. sep2 .. args[#args];
   end
   return res

end

function join.concat(frame)

   local res=;
   for k,v in pairs( frame.args ) do
        res = res .. v
   end
   return res

end

function join.iconcat(frame)

   local res=;
   for k,v in ipairs( frame.args ) do
        res = res .. v
   end
   return res

end

return join