Difference between revisions of "Module:ApplyPattern"

From Holdfast: Nations At War
Jump to navigation Jump to search
m
Line 1: Line 1:
 
local p = {}
 
local p = {}
 
function p.apply(frame)
 
function p.apply(frame)
    return 'Hello, my ' .. frame.args[1] .. ' is ' .. string.gsub(frame.args[2], '%%pattern%%',frame.args[1])
+
local list = frame.args[1]
 +
local pattern = frame.args[2]
 +
local result = ""
 +
 +
 +
local entry = list
 +
 +
result = result .. string.gsub(pattern, '%%pattern%%',entry)
 +
 +
    return result
 
end
 
end
 
return p
 
return p

Revision as of 14:38, 17 August 2019

Custom module to apply either some wiki markup or a template to each item in a comma delimited list. Look at Template:Class for examples.


local p = {}
function p.apply(frame)
	local list = frame.args[1]
	local pattern = frame.args[2]
	local result = ""
	
	
	local entry = list
	
	result = result .. string.gsub(pattern, '%%pattern%%',entry)
	
    return result
end
return p