বিষয়বস্তুতে চলুন

মডিউল:scripts/templates

উইকিঅভিধান, মুক্ত অভিধান থেকে

এই মডিউলের জন্য মডিউল:scripts/templates/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে

local export = {}

function export.exists(frame)
	return require("Module:scripts").getByCode(
		require("Module:parameters").process(frame.args, {
			[1] = {required = true}
		})[1]
	) and "1" or ""
end

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

function export.getByCanonicalName(frame)
	local sc = require("Module:scripts").getByCanonicalName(
		require("Module:parameters").process(frame.args, {
			[1] = {required = true}
		})[1]
	)
	return sc and sc:getCode() or "None"
end

function export.findBestScript(frame)
	local args = require("Module:parameters").process(frame.args, {
		[1] = {required = true},
		[2] = {required = true, type = "language"},
		[3] = {}
	})
	if args[3] == "getCanonicalName" then
		return args[2]:findBestScript(args[1]):getCanonicalName()
	else
		return args[2]:findBestScript(args[1]):getCode()
	end
end

return export