Module:If empty: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>Codehydro lua doesn't cast nil into blank strings apparently |
meta>Codehydro m test: do I even need these lines? |
||
Line 1: | Line 1: | ||
-- this is intended to replace {{If empty}} | -- this is intended to replace {{If empty}} | ||
function p.run(frame) | function p.run(frame) | ||
local args = require('Module:Arguments').getArgs(frame) | local args = require('Module:Arguments').getArgs(frame) | ||
Line 10: | Line 9: | ||
return args[i] | return args[i] | ||
end | end | ||
Revision as of 19:01, 23 December 2014
Documentation for this module may be created at Module:If empty/doc
-- this is intended to replace {{If empty}}
function p.run(frame)
local args = require('Module:Arguments').getArgs(frame)
local i = 0
args[table.getn(args)] = ''
while args[i] == nil or string.len(args[i]) == 0 do
i = i + 1
end
return args[i]
end