Module:Sandbox/Jackmcbarn/variables/sandbox
This is the module sandbox page for Module:Sandbox/Jackmcbarn/variables (diff). |
This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
Usage
DON'T USE THIS, OR ANYTHING LIKE IT. EVER. SERIOUSLY.
*Setting somekey to somevalue (shouldn't see anything): {{#invoke:Sandbox/Jackmcbarn/variables|set|somekey|somevalue}} *Setting otherk to otherv (shouldn't see anything): {{#invoke:Sandbox/Jackmcbarn/variables|set|otherk|otherv}} *Getting somekey: {{#invoke:Sandbox/Jackmcbarn/variables|get|somekey}} *Getting otherk: {{#invoke:Sandbox/Jackmcbarn/variables|get|otherk}} *Getting somekey: {{#invoke:Sandbox/Jackmcbarn/variables|get|somekey}} *Getting otherk: {{#invoke:Sandbox/Jackmcbarn/variables|get|otherk}} *Clearing all variables (shouldn't see anything): {{#invoke:Sandbox/Jackmcbarn/variables|done}}
Produces:
- Setting somekey to somevalue (shouldn't see anything):
- Setting otherk to otherv (shouldn't see anything):
- Getting somekey:
- Getting otherk:
- Getting somekey:
- Getting otherk:
- Clearing all variables (shouldn't see anything):
{{#invoke:Sandbox/Jackmcbarn/variables|function_name}}
local p = {}
function p.set(frame)
frame:extensionTag{name = 'ref', content = frame.args[2], args = { group = 'lower-greek', name = frame.args[1] }}
return ''
end
function p.get(frame)
local refText = mw.text.unstrip(frame:extensionTag{name = 'references', args = { group='lower-greek' }})
local keyMatch = mw.ustring.gmatch(refText, '<li id="cite_note%-([^-]*)%-%d+">')
local valMatch = mw.ustring.gmatch(refText, '<span class="reference%-text">([^<]*)')
local variables = {}
for key in keyMatch do
variables[key] = valMatch()
frame:extensionTag{name = 'ref', content = variables[key], args = { group = 'lower-greek', name = key }}
end
return variables[frame.args[1]]
end
function p.done(frame)
frame:extensionTag{name = 'references', args = { group='lower-greek' }}
return ''
end
return p