Module:Template wrapper: Difference between revisions
From Vigyanwiki
Template>Trappist the monk No edit summary |
Template>Trappist the monk No edit summary |
||
Line 7: | Line 7: | ||
local template; | local template; | ||
for k, v in pairs (frame.args) do | for k, v in pairs (frame.args) do -- here we get the wrapper template's 'default' parameters | ||
if 'template' == k then | if 'template' == k then | ||
template = v; -- save the name of template that we are wrapping | template = v; -- save the name of template that we are wrapping | ||
Line 13: | Line 13: | ||
args[k] = v; -- copy frame parameters to args table | args[k] = v; -- copy frame parameters to args table | ||
end | end | ||
end | |||
if nil == template or '' == template then -- this is the one parameter required by this module | |||
return '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inherit; padding:inherit;\">|template=</code> missing or empty</span>'; | |||
end | end | ||
local pframe = frame:getParent(); | local pframe = frame:getParent(); -- here we get the wrapper template's 'live' parameters | ||
for k, v in pairs (pframe.args) 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 |
Revision as of 21:08, 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 -- here we get the wrapper template's 'default' parameters
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
if nil == template or '' == template then -- this is the one parameter required by this module
return '<span style=\"font-size:100%\" class=\"error\"><code style=\"color:inherit; border:inherit; padding:inherit;\">|template=</code> missing or empty</span>';
end
local pframe = frame:getParent(); -- here we get the wrapper template's 'live' parameters
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;