Jump to content

Module talk:Template wrapper

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JJMC89 (talk | contribs) at 18:36, 19 August 2018 (ipairs, mot pairs). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

using positional parameters

This module was initially written so that positional parameters in the wrapper template are not passed on to the working template. That's fine for templates like the cs1|2 templates because they do not use positional parameters but is problematic for templates like {{ERIC}} which wraps {{Catalog_lookup_link}}.

So I've invented a new parameter for Module:template wrapper: |_pass-all= which when set to yes in the module {{#invoke:}} causes the module to pass all wrapper-template parameters except those listed in |_exclude= to the working template. Here is {{ERIC/sandbox}} which uses Module:template wrapper/sandbox with |_pass-all=yes to wrap {{Catalog_lookup_link/sandbox}} which invokes Module:Catalog_lookup_link/sandbox:

{{ERIC/sandbox|ED046562|EJ671671|url-access=free}}
ERIC ED046562, EJ671671

Here is {{EFloras/sandbox2}} which uses Module:template wrapper/sandbox without |_pass-all= to wrap {{cite web}} which invokes Module:Citation/CS1. Positional parameters are used by {{EFloras}} and not passed to {{cite web}}:

{{EFloras/sandbox2|1|233501007|Quercus alba |volume=3 |first=Kevin C. |last=Nixon | access-date = 18 August 2018 }}
Nixon, Kevin C. (1997). "Quercus alba". Flora of North America North of Mexico (FNA). Vol. 3. New York and Oxford. Retrieved 18 August 2018 – via eFloras.org, Missouri Botanical Garden, St. Louis, MO & Harvard University Herbaria, Cambridge, MA. {{citation}}: External link in |via= (help); Unknown parameter |editors= ignored (|editor= suggested) (help)CS1 maint: location missing publisher (link)

Compare the live {{Efloras}}:

{{EFloras|1|233501007|Quercus alba |volume=3 |first=Kevin C. |last=Nixon | access-date = 18 August 2018 }}
Nixon, Kevin C. (1997). "Quercus alba". In Flora of North America Editorial Committee (ed.). Flora of North America North of Mexico (FNA). Vol. 3. New York and Oxford: Oxford University Press. Retrieved 18 August 2018 – via eFloras.org, Missouri Botanical Garden, St. Louis, MO & Harvard University Herbaria, Cambridge, MA.

What have I missed?

Trappist the monk (talk) 11:29, 19 August 2018 (UTC)[reply]

Unless I'm misunderstanding something, the below looks like it will add all the positional pframe_args regardless of |_exclude= or unset.
	if pass_all then
		for i, v in ipairs (pframe_args) do
			add_parameter (i, v, args, list);
		end
	end
I think the below would do what you intend.
local function pframe_args_get (pframe_args, args, exclude, pass_all, list)
	for k, v in pairs (pframe_args) do
		if (pass_all or type (k) ~= 'number') and not is_in_table (exclude, k) then	-- do not pass along excluded parameters
			if v and ('' ~= v) then													-- pass along only those parameters that have assigned values
				if 'unset' == v:lower() then										-- special keyword to unset 'default' parameters set in the wrapper template
					v = '';															-- unset the value in the args table
				end
				add_parameter (k, v, args, list)									-- add all other parameters to args in the style dictated by list
			end
		end
	end
end
It might make more sense to use |_pass_positional= instead of |_pass-all= since |_exclude= still applies. frame_args_get should also be adjusted so that the new parameter isn't passed. — JJMC89(T·C) 18:11, 19 August 2018 (UTC)[reply]