Module:Separated entries/testcases
|
|
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
|
|
මෙම Lua module පිටු බොහෝ ගණනක භාවිතා වන නිසා සිදුකරන වෙනස් කිරීම් බොහෝ ස්ථානවලට බලපානු ඇත. ඔබ සිදුකිරීමට අදහස් කරන වෙනස්කම් මෙම මොඩියුලයට අදාළ /sandbox හෝ /testcases උපපිටු. එම වෙනස්කම් සිදුකිරීමට ප්රථම අදාළ සාකච්ඡා පිටුවේ ඒ පිළිබඳව සංවාදයක් ගොඩනැගීමට කාරුණික වන්න.
Transclusion count updated automatically (ප්රලේඛනය වෙතට යොමුවන්න). |
| මෙම මොඩියුලයට අවශ්ය අනෙකුත් මොඩියුල මත: |
Usage
[සංස්කරණය]Module:Separated entries and {{Separated entries}} serve as a template front-end to mw.text.listToText. They take any number of positional parameters and piece them together with |separator=. |conjunction= can be optionally defined if a different separator is desired between the last and second last items. The starting positional parameter can be specified using |start=. Leading and trailing whitespace is stripped. To add deliberate leading and trailing whitespace, use the HTML entity   for a space and for a "newline". Separated entries does not raise any errors by design.
{{#invoke:separated entries|main|separator=...}}
For more complex cases – such as selecting the parameters to list, or preprocessing them, or omitting the last parameters – සැකිල්ල:Mfl is available. The following two examples with “ + ” as delimiter and “ ... ” as conjunction produce a similar result:
{{#invoke:separated entries|main|separator= + |conjunction= ... }}{{#invoke:params|sequential|squeezing|trimming_values|setting|i/l| + | ... |list_values}}
See also
[සංස්කරණය]- {{Enum}}
- {{Br separated entries}}
- සැකිල්ල:Mfl
-- Unit tests for [[Module:Separated entries]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_main()
self:preprocess_equals_many('{{#invoke:Separated entries|main|', '}}', {
{'', ''},
{'A', 'A'},
{'A|B', 'AB'},
{'A||B', 'AB'}, -- empty parameter
{'A|B|C', 'ABC'},
{'separator=,', ''},
{'separator=,|A', 'A'},
{'separator=,|A|B', 'A,B'},
{'separator=,|A||B', 'A,B'}, -- empty parameter
{'conjunction=;', ''},
{'conjunction=;|A', 'A'},
{'conjunction=;|A|B', 'A;B'},
{'separator=,|conjunction=;', ''},
{'separator=,|conjunction=;|A', 'A'},
{'separator=,|conjunction=;|A|B', 'A;B'},
{'separator=,|conjunction=;|A|B|C', 'A,B;C'},
{'separator=,|conjunction=;|A|B|C|D', 'A,B,C;D'},
{'start=2|separator=,|conjunction=;|A|B|C|D', 'B,C;D'},
{'dataPlural=1', ''},
{'dataPlural=1|A', 'A'},
{'dataPlural=1|A|B', 'AB'},
{'dataPlural=1|A||B', 'AB'}, -- empty parameter
{'dataPlural=1|A|B|C', 'ABC'},
{'dataPlural=1|separator=,', ''},
{'dataPlural=1|separator=,|A', 'A'},
{'dataPlural=1|separator=,|A|B', 'A,B'},
{'dataPlural=1|separator=,|A||B', 'A,B'}, -- empty parameter
{'dataPlural=1|conjunction=;', ''},
{'dataPlural=1|conjunction=;|A', 'A'},
{'dataPlural=1|conjunction=;|A|B', 'A;B'},
{'dataPlural=1|separator=,|conjunction=;', ''},
{'dataPlural=1|separator=,|conjunction=;|A', 'A'},
{'dataPlural=1|separator=,|conjunction=;|A|B', 'A;B'},
{'dataPlural=1|separator=,|conjunction=;|A|B|C', 'A,B;C'},
{'dataPlural=1|separator=,|conjunction=;|A|B|C|D', 'A,B,C;D'},
{'dataPlural=1|start=2|separator=,|conjunction=;|A|B|C|D', 'B,C;D'},
},{nowiki=1})
end
function p:test_sandbox()
self:preprocess_equals_many('{{#invoke:Separated entries/sandbox|main|', '}}', {
{'', ''},
{'A', 'A'},
{'A|B', 'AB'},
{'A||B', 'AB'}, -- empty parameter
{'A|B|C', 'ABC'},
{'separator=,', ''},
{'separator=,|A', 'A'},
{'separator=,|A|B', 'A,B'},
{'separator=,|A||B', 'A,B'}, -- empty parameter
{'conjunction=;', ''},
{'conjunction=;|A', 'A'},
{'conjunction=;|A|B', 'A;B'},
{'separator=,|conjunction=;', ''},
{'separator=,|conjunction=;|A', 'A'},
{'separator=,|conjunction=;|A|B', 'A;B'},
{'separator=,|conjunction=;|A|B|C', 'A,B;C'},
{'separator=,|conjunction=;|A|B|C|D', 'A,B,C;D'},
{'start=2|separator=,|conjunction=;|A|B|C|D', 'B,C;D'},
{'dataPlural=1', ''},
{'dataPlural=1|A', 'A'},
{'dataPlural=1|A|B', 'AB'},
{'dataPlural=1|A||B', 'AB'}, -- empty parameter
{'dataPlural=1|A|B|C', 'ABC'},
{'dataPlural=1|separator=,', ''},
{'dataPlural=1|separator=,|A', 'A<span style="display:none" data-plural="0"></span>'},
{'dataPlural=1|separator=,|A|B', 'A,B<span style="display:none" data-plural="1"></span>'},
{'dataPlural=1|separator=,|A||B', 'A,B<span style="display:none" data-plural="1"></span>'}, -- empty parameter
{'dataPlural=1|conjunction=;', ''},
{'dataPlural=1|conjunction=;|A', 'A<span style="display:none" data-plural="0"></span>'},
{'dataPlural=1|conjunction=;|A|B', 'A;B<span style="display:none" data-plural="1"></span>'},
{'dataPlural=1|separator=,|conjunction=;', ''},
{'dataPlural=1|separator=,|conjunction=;|A', 'A<span style="display:none" data-plural="0"></span>'},
{'dataPlural=1|separator=,|conjunction=;|A|B', 'A;B<span style="display:none" data-plural="1"></span>'},
{'dataPlural=1|separator=,|conjunction=;|A|B|C', 'A,B;C<span style="display:none" data-plural="1"></span>'},
{'dataPlural=1|separator=,|conjunction=;|A|B|C|D', 'A,B,C;D<span style="display:none" data-plural="1"></span>'},
{'dataPlural=1|start=2|separator=,|conjunction=;|A|B|C|D', 'B,C;D<span style="display:none" data-plural="1"></span>'},
},{nowiki=1})
end
return p