Module talk:Template test case: Difference between revisions

Content deleted Content added
Trim input's newlines?: reply to Andrybak: Yes, thanks. (-)
Line 250:
:? That is, trim newlines which are right next to the outer pair of {{tag|nowiki}} tags. —⁠[[User:Andrybak|andrybak]] ([[User talk:Andrybak|talk]]) 22:47, 8 August 2024 (UTC)
::Yes, thanks. [[User:Aaron Liu|<span style="color:#0645ad">Aaron Liu</span>]] ([[User talk:Aaron Liu#top|talk]]) 23:28, 8 August 2024 (UTC)
 
== Having multiple __TEMPLATENAME__s ==
 
I wanted to gauge interest in possibly extending the Module code to (optionally) support testing nowiki'd code that contains ''multiple'' template name substitutions. The primary use case would be testing templates that are only useful in concert with others, like (for example) {{tlx|archive top}}.
 
It's certainly possible to test that template in isolation, using a {{tlx|Test case nowiki}} transclusion at [[Template:Archive top/testcases]] like:
 
<syntaxhighlight lang="mediawiki">
{{Test case nowiki|<nowiki>
{{__TEMPLATENAME__}}
{{Lorem ipsum}}
{{archive bottom}}
</nowiki>}}
</syntaxhighlight>
 
...That'll get you a perfectly good test of {{tlx|archive top}} vs. {{tlx|archive top/sandbox}}.
 
But it might be useful, at times, to pair the tested {{tlx|archive top}} with a '''corresponding''' {{tlx|archive bottom}}, for when changes being made in tandem are being tested.
 
To meet those needs, the Module might need to support something like the following:
 
<syntaxhighlight lang="mediawiki">
{{Test case nowiki|template1name1=archive top|template1name2=archive bottom|<nowiki>
{{__TEMPLATENAME1__}}
{{Lorem ipsum}}
{{__TEMPLATENAME2__}}
</nowiki>}}
</syntaxhighlight>
 
This would, my thinking goes, permit testing the '''''combination''''' of {{tlx|archive top}} and {{tlx|archive bottom}} against the '''''combination''''' of {{tlx|archive top/sandbox}} and {{tlx|archive bottom/sandbox}} (unless different templates were specified for {{para|template2name1}} and {{para|template2name2}}).
 
As with the citation templates' handling of {{para|author}}, {{para|first}}, {{para|last}}, etc.:
 
# {{para|template1}} would effectively become an alias for {{para|template1name1}} (with the same default of <syntaxhighlight lang="mediawiki" inline>{{#titleparts: {{PAGENAME}}| -1}}</syntaxhighlight>)
# Same for {{para|template2}} and {{para|template2name1}} (again having the same default of <syntaxhighlight lang="mediawiki" inline>{{{template1name1}}}/sandbox</syntaxhighlight>)
# {{para|template3}} == {{para|template3name1}}, etc.
# <code>__TEMPLATENAME__</code> would be interchangeable with <code>__TEMPLATENAME1__</code>.
 
Using only {{para|template1name1}}, {{para|template2name1}}, and <code>__TEMPLATENAME1__</code> would therefore be equivalent to the current syntax, as would using ''only'' <code>__TEMPLATENAME1__</code> and leaving the template-selection parameters at their default values.
 
...Potentially useful? Some flaw I've overlooked in the proposed functionality? Or just not worth the effort, regardless whether or not it would work? [[User:FeRDNYC|FeRDNYC]] ([[User talk:FeRDNYC|talk]]) 18:21, 29 August 2024 (UTC)