Module:Template wrapper: Difference between revisions
From Vigyanwiki
Template>Trappist the monk (←Created page with 'require('Module:No globals'); p={} function p.cs1_wrapper (frame) local args = {}; local template; for k, v in pairs (frame.args) do if 'template' == k...') |
Template>Trappist the monk No edit summary |
||
Line 1: | Line 1: | ||
require('Module:No globals'); | require('Module:No globals'); | ||
p={} | local p={}; | ||
function p.cs1_wrapper (frame) | function p.cs1_wrapper (frame) | ||
Line 16: | Line 16: | ||
local pframe = frame:getParent(); | local pframe = frame:getParent(); | ||
for k, v in pairs (pframe) do | for k, v in pairs (pframe.args) do | ||
args[k] = v; -- copy parent frame parameters to args table | args[k] = v; -- copy parent frame parameters to args table | ||
end | end | ||
return frame:expandTemplate | return frame:expandTemplate {title=template, args=args}; -- render the citation | ||
end | end | ||
return p; | return p; |
Revision as of 03:23, 27 December 2017
Documentation for this module may be created at Module:Template wrapper/doc
require('Module:No globals');
local p={};
function p.cs1_wrapper (frame)
local args = {};
local template;
for k, v in pairs (frame.args) do
if 'template' == k then
template = v; -- save the name of template that we are wrapping
else
args[k] = v; -- copy frame parameters to args table
end
end
local pframe = frame:getParent();
for k, v in pairs (pframe.args) do
args[k] = v; -- copy parent frame parameters to args table
end
return frame:expandTemplate {title=template, args=args}; -- render the citation
end
return p;