Toggle search
Search
Toggle menu
notifications
Toggle personal menu
Editing
Module:DemoTemplate
From Celestial Compass Roleplaying Wiki
Views
Read
Edit source
View history
associated-pages
Module
Discussion
More actions
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!
require('strict') local newBuffer = require('Module:OutputBuffer') local mt = {} function mt.__index(t, title) return function(frame) local getBuffer, print, printf = newBuffer() printf('{{%s', title) local ipairsArgs = {} for k,v in ipairs(frame.args) do if string.find(v, '=', 1, true) then break end ipairsArgs[k] = true printf('|%s', v) end for k,v in pairs(frame.args) do if not ipairsArgs[k] then printf('|%s=%s', string.gsub(k, '=', '{{=}}'), v) end end print('}}') local buffer = getBuffer() -- rather than calling expandTemplate with the title and args we have, call preprocess, so that our code example will always match our output, even in the cases of pipes or other things we should have escaped but didn't return string.format('<code>%s</code> → %s', mw.text.nowiki(buffer), frame:preprocess(buffer)) end end return setmetatable({}, mt)
Summary:
Please note that all contributions to Celestial Compass Roleplaying Wiki 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
CCRPWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:DemoTemplate/doc
(
edit
)