Module:scripts/templates: Difference between revisions
Chrysophylax (talk | contribs) Created page with "local export = {} function export.exists(frame) local args = frame.args local sc = args[1] or error("Script code has not been specified. Please pass parameter 1 to the modu..." |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
function export.exists(frame) | function export.exists(frame) | ||
return require("Module:scripts").getByCode( | |||
require("Module:parameters").process(frame.args, { | |||
[1] = {required = true} | |||
})[1] | |||
) and "1" or "" | |||
end | end | ||
function export.getByCode(frame) | function export.getByCode(frame) | ||
return require("Module:language-like").templateGetByCode( | |||
require("Module:parameters").process(frame.args, { | |||
[1] = {required = true, type = "script"}, | |||
[2] = {required = true}, | |||
[3] = {} | |||
}), | |||
function(itemname) | |||
if itemname == "countCharacters" then | |||
local text = args[3] or "" | |||
return args[1]:countCharacters(text) | |||
end | |||
end | end | ||
) | |||
end | end | ||
function export.getByCanonicalName(frame) | function export.getByCanonicalName(frame) | ||
local sc = require("Module:scripts").getByCanonicalName( | |||
local sc = | require("Module:parameters").process(frame.args, { | ||
[1] = {required = true} | |||
})[1] | |||
) | |||
return sc and sc:getCode() or "None" | |||
end | end | ||
function export. | function export.findBestScriptWithoutLang(frame) | ||
local | local sc = require("Module:scripts").findBestScriptWithoutLang( | ||
require("Module:parameters").process(frame.args, { | |||
[1] = {required = true} | |||
})[1] | |||
) | |||
return sc or "None" | |||
return | |||
end | end | ||
return export | return export | ||