Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:Template
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local Arguments = require('Module:Arguments') local Json = require('Module:Json') local PageVariableNamespace = require('Module:PageVariableNamespace') local Template = {} function Template.safeExpand(frame, title, args, defaultTemplate) local result, value = pcall(frame.expandTemplate, frame, {title = title, args = args}) if result then return value else local templateName = '[[Template:' .. (title or '') .. ']]' return defaultTemplate or templateName end end function Template.expandTemplate(frame, title, args) return frame:expandTemplate {title = title, args = args} end --[[ Stores a value that a function would otherwise return in a place to be later retrieved by Template.retrieveReturnValues. Used to return values across template boundaries. ]] function Template.stashReturnValue(value, namespace) local pageVars = PageVariableNamespace(namespace or 'Template.return') local count = tonumber(pageVars:get('count')) or 0 count = count + 1 pageVars:set(count, Json.stringify(value)) pageVars:set('count', count) return '' end --[[ Retrieves all values stashed by Template.stashReturnValue. ]] function Template.retrieveReturnValues(namespace) local pageVars = PageVariableNamespace(namespace or 'Template.return') local count = tonumber(pageVars:get('count')) or 0 pageVars:delete('count') local values = {} for i = 1, count do values[i] = Json.parse(pageVars:get(i)) pageVars:delete(i) end return values end --[[ Variant of Template.stashReturnValue suitable for use by #invoke. Stores the arguments of a template call in a place to be later retrieved by Template.retrieveReturnValues. {{#invoke:Template|stashArgs}} has the same interface as {{#invoke:Json|fromArgs}}. Usage: {{#invoke:Template|stashArgs|foo=3|namespace=Magpie}} will make {foo = '3'} available for retrival via Template.retrieveReturnValues('Magpie') . ]] function Template.stashArgs(frame) local args = Arguments.getArgs(frame) local namespace = args.namespace args.namespace = nil return Template.stashReturnValue(args, namespace) end return Template
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Template/doc
(
edit
)
No categories
Edit