Module:Consecutive links: Difference between revisions

m
no edit summary
(big refactor, shouldn't break anything?)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 19: Line 19:
local linkprefix = args[6] or ''
local linkprefix = args[6] or ''
local linkpostfix = args[7] or ''
local linkpostfix = args[7] or ''
local textprefixindicator = args[8] or ''
local textprefix = args[9] or ''


local b = p.split(args[1], separator)
local b = p.split(args[1], separator)
Line 25: Line 27:


if type == 'links' then
if type == 'links' then
   returnstrformat = function(linkprefix, word, linkpostfix)
   returnstrformat = function(linkprefix, word, linkpostfix, indicator, textprefix)
     return '[[' .. linkprefix .. word .. linkpostfix .. ']]'
  fronttext = ''
  if indicator ~= '' and string.sub(word, 1, string.len(indicator)) == indicator then
  word = string.sub(word, string.len(indicator) + 1)
  fronttext = textprefix
  end
     return fronttext .. '[[' .. linkprefix .. word .. linkpostfix .. ']]'
     end
     end
elseif type == 'templates' then
elseif type == 'templates' then
   returnstrformat = function(linkprefix, word, linkpostfix)
   returnstrformat = function(linkprefix, word, linkpostfix, indicator, textprefix)
     return frame:expandTemplate{title = linkprefix, args={word, linkpostfix}}
     return frame:expandTemplate{title = linkprefix, args={word, linkpostfix}}
     end
     end
Line 39: Line 46:
     returnstr = returnstr .. replacer  
     returnstr = returnstr .. replacer  
   end
   end
   returnstr = returnstr .. returnstrformat(linkprefix, word, linkpostfix)
   returnstr = returnstr .. returnstrformat(linkprefix, word, linkpostfix, textprefixindicator, textprefix)
end
end
return returnstr
return prefix .. returnstr .. postfix
end
end


Line 54: Line 61:


function p.test(frame)
function p.test(frame)
   return p.parse({'Joppa,Grit Gate,Bey Lah', nil, nil, nil, nil, 'favilink', nil}, 'templates')
   str = '{{SkillID to name|Axe}} </br>{{SkillID to name|Axe_Expertise}}'
  separator = '</br>'
  replacer = '</div><div class{{=}}"qud-skill-entry">'
local prefix ='<div class{{=}}"qud-skill-entry">'
local postfix = '</div>'
  args = {str, separator, replacer, prefix, postfix}
  return p.parse(args, 'links')
end
end
return p
return p