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 }}
{{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 }}
What have I missed?
—Trappist the monk (talk) 11:29, 19 August 2018 (UTC)
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
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
|_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)
{{{1}}}
and exclude {{{2}}}
what do we do with {{{3}}}
et seq.? Does {{{3}}}
become the new {{{2}}}
? I just didn't want to venture along that cow track until there is a demonstrated need to go there.unset
value. I'll fix that.ipairs()
as I did ensures that empty positional parameters are passed along to the working template. In the pairs()
version, the if v and ('' ~= v) then
prevents empty positional parameters from being added to the args
table.|_pass-all=
to frame_args_get()
; I'll do that. As you can see I was not very successful in finding a good parameter name. |_pass-all=
is the shortest I could come up with and was, I felt, marginally better than |_pass-positional=
which I felt implied 'only' but was shorter than |_include-positional=
which was the best in terms of describing what it does at the expense of length; I was hoping for a single word but was unable to find one that is suitable. I'll change to |_include-positional=
.|_include-positional=
; I agree it would be difficult to properly handle. I made this edit. I think the sandbox looks good now. — JJMC89 (T·C) 21:53, 19 August 2018 (UTC)
{{{1}}}
in the call to the working template 'bumps' the subsequent positional parameters: wrapper template {{{2}}}
becomes working template {{{1}}}
and so on. For {{multiref2}}
that doesn't much matter but for other templates it can make a hash of things.I have added code so that the wrapper templates can support parameter aliasing and same-name reuse. Also updated the documentation. Existing applications should not notice the change. But, famous last words, those, report anomalies here.
—Trappist the monk (talk) 13:46, 17 November 2018 (UTC)
@Pppery: If you are going to make changes to this module, please document those changes both in the code and in the doc page.
Please explain this:
if mw.isSubsting() and frame.args._substall == "no" then
return require("Module:Template invocation").invocation(template, args)
else
return frame:expandTemplate {title=template, args=args}; -- render the working template
end
How is the one different from the other?
—Trappist the monk (talk) 19:09, 19 February 2019 (UTC)
{{#invoke:Template wrapper|wrap|_template=X2|xxx=yyy|_substall={{{_substall}}}|_exclude=_substall}}
. If |_substall=no
is specified, then substing Template:X1 will produce a transclusion of Template:X2, as opposed to a substitution of Template:X2 which is produced without the _substall param. {{3x|p}}ery (talk) 19:14, 19 February 2019 (UTC)
Why doesn't this work?
Code:
{{#invoke:Template wrapper|wrap|_template=IPA|_reuse=1|_include-positional=yes|1=⫽{{{1}}}⫽}}
Markup | Renders as |
---|---|
{{IPA double slash/sandbox|r}} |
r |
Nardog (talk) 18:00, 29 December 2024 (UTC)
{{{1}}}
positional parameters:
{{IPA double slash/sandbox|r}}
– r
is {{{1}}}
{{#invoke:Template wrapper|wrap|_template=IPA|_reuse=1|_include-positional=yes|1=⫽{{{1}}}⫽}}
– |1=
is also {{{1}}}
{{IPA|⫽{{{1}}}⫽}}
_reuse
. Nardog (talk) 22:18, 29 December 2024 (UTC)
{{IPA double slash}}
. Does it not do what you want it to do?{{IPA double slash}}
invokes Module:IPA via {{IPA}}
, have you considered adding an exported function to that module that would do what you want and therefore skip the IPA template altogether?{{IPA}}
parameter {{{1}}}
? Sommat like:
{{IPA double slash/sandbox|text=r}}
{{#invoke:Template wrapper|wrap|_template=IPA|_reuse=text|text=⫽{{{text}}}⫽}}
args[1] = args[1] or args.text;
{{IPA double slash/sandbox}}
as described in #2 above except that I switched wrap
to list
. When I previewed my sandbox with the tweaked template sandbox, Module:Template wrapper gave me:
{{IPA|text=⫽r⫽}}
{{IPA double slash/sandbox|text=r|lang=es}}
{{IPA double slash/sandbox|r|lang=es}}
{{#invoke:Template wrapper|list|_template=IPA|_reuse=text|text=⫽{{{text|{{{1|}}}}}}⫽}}
{{IPA|lang=es|text=⫽r⫽}}
{{IPA|lang=es|text=⫽r⫽}}
what can I do to make the template output essentially the same thing as {{IPA|⫽{{{1}}}⫽}}
except all other arguments are passed on to {{IPA}}?
|_reuse=
. Of course anything is possible if you just modify the template being transcluded; that's clearly not what I'm asking, or I wouldn't post it here. So does the module not support what is described in the doc but for a positional parameter? Shouldn't it? Nardog (talk) 01:52, 30 December 2024 (UTC)
|_reuse=
is not supported for positional parameters.