Module talk:Template wrapper
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:
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
(help); Unknown parameter|via=
|editors=
ignored (|editor=
suggested) (help)CS1 maint: location missing publisher (link)
- 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.
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)
- Unless I'm misunderstanding something, the below looks like it will add all the positional
pframe_args
regardless of|_exclude=
orunset
.I think the below would do what you intend.if pass_all then for i, v in ipairs (pframe_args) do add_parameter (i, v, args, list); end end
It might make more sense to uselocal 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
|_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)