Content deleted Content added
→Works: Reply |
→Works: Reply |
||
Line 193:
:The technical reason for why comes down to [[Module:Template test case#L-770|this bit of code]], in which the nowiki wrapper has its arguments done differently. The reason I think this was done in practice is because the only reason the underscores are used in the {{tl|Test case}} version is because you have to provide the real arguments, so prefixing the options with _ prevents conflicts. Since the nowiki version just takes the parameter 1, it had no need for the underscores. [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 06:57, 15 July 2023 (UTC)
::<nowiki>*nod*</nowiki> I totally understand why the _-prefixed arguments are needed for the other templates, and why {{tlx|Test case nowiki}} can do without them. But in the interests of... I don't know, consistency, harmony, whatever, it seems like <code>bridge.nowiki</code> could include this logic:<syntaxhighlight lang="lua">
:: local options = {}
:: for k, v in pairs(args) do
:: local underscoreOptionKey = type(k) == 'string' and k:match('^_(.*)$')
:: if underscoreOptionKey then
:: options[underscoreOptionKey] = v
:: else
:: options[k] = v
:: end
:: end
:: local code = options.code or options[1]
:: local invocationObj = NowikiInvocation.new(code, cfg)
:: options.code = nil
:: options[1] = nil
:: -- Assume we want to see the code as we already passed it in.
:: options.showcode = options.showcode or true
:: local testCaseObj = TestCase.new(invocationObj, options, cfg)
::</syntaxhighlight>
::...So that e.g. {{para|_collapsible}} and {{para|collapsible}} are equivalent, meaning the user has the option to pass the exact same arguments as all the other templates in the group. [[User:FeRDNYC|FeRDNYC]] ([[User talk:FeRDNYC|talk]]) 18:44, 15 July 2023 (UTC)
|