Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Service history generator: Difference between revisions

From CHIPPS
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
function servicehist_gen(str)
function servicehist_gen(str)
   for line in str.gmatch("\n")
  local out = ""
   for line in str:gmatch("[^\n]+")
   do
   do
     mw.log(line)
     local from, to, rr = line:match("([%d-]+) to ?([%d-]*): ([^\n|]+)")
    out = out .. "{{Service history entry|"..rr.."|"..(from or "").."|"..(to or "").."}} "
   end
   end
  return out
end
end


local p=
return
{
{
     servicehist_gen = servicehist_gen,
     servicehist_gen = servicehist_gen,
     gen = function(frame)
     gen = function(frame)
       return servicehist_gen(frame:getParent().args.servicehist_f)
       local pargs = frame:getParent().args
      if pargs.servicehist or pargs.servicehist_f
      then
        return frame:preprocess("{{infobox service history|"..
          (pargs.servicehist or servicehist_gen(pargs.servicehist_f)).."}}")
      end
     end
     end
}
}

Latest revision as of 02:16, 2 November 2025

Documentation for this module may be created at Module:Service history generator/doc

function servicehist_gen(str)
  local out = ""
  for line in str:gmatch("[^\n]+")
  do
    local from, to, rr = line:match("([%d-]+) to ?([%d-]*): ([^\n|]+)")
    out = out .. "{{Service history entry|"..rr.."|"..(from or "").."|"..(to or "").."}} "
  end
  return out
end

return
{
    servicehist_gen = servicehist_gen,
    gen = function(frame)
      local pargs = frame:getParent().args
      if pargs.servicehist or pargs.servicehist_f
      then
        return frame:preprocess("{{infobox service history|"..
          (pargs.servicehist or servicehist_gen(pargs.servicehist_f)).."}}")
      end
    end
}