21:
95:
52:
956:
Although the empty string usually evaluates to false in wikitext, it evaluates to true in Lua. This module prefers the Lua behaviour over the wikitext behaviour. If treating the empty string as false is important for your module, you will need to convert empty strings to a value that evaluates to
130:
boolean values, wikicode templates can only express boolean values through strings such as "yes", "no", etc. This module processes these kinds of strings and turns them into boolean input for Lua to process. It also returns
147:. The module also accepts other Lua structures as input, i.e. booleans, numbers, tables, and functions. If it is passed input that it does not recognise as boolean or
1855:
101:
112:
very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is
1373:
212:
First, load the module. Note that it can only be loaded from other Lua modules, not from normal wiki pages. For normal wiki pages you can use
1358:
630:
You can specify a default value if yesno receives input other than that listed above. If you don't supply a default, the module will return
1346:
36:
1328:
1384:
1342:
32:
105:
113:
122:
This module provides a consistent interface for processing boolean or boolean-style string input. While Lua allows the
1377:
957:
false before passing them to this module. In the case of arguments received from wikitext, this can be done by using
40:
109:
1860:
1368:
73:
184:
is the value to be tested. Boolean input or boolean-style input (see below) always evaluates to either
1353:
69:
1441:-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
80:. The tested changes can be added to this page in a single edit. Please discuss changes on the
1332:
81:
1336:
958:
28:
68:
To avoid major disruption and server load, any changes should be tested in the module's
1448:-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
216:
77:
1849:
1137:-- When value is nil, result is true. (XXX: when value is false, result is true...)
66:
Changes to it can cause immediate changes to the
Knowledge (XXG) user interface.
61:
1398:-- Function allowing for consistent treatment of boolean-like wikitext input.
15:
62:
approximately 29,900,000 pages, or roughly 49% of all pages
492:
String values are converted to lower case before they are matched:
89:
46:
1362:
151:, it is possible to specify a default value to return.
1197:-- Default value (here: true) applies, result is true.
1258:-- more efficient when value is nil, but more verbose
1261:-- (note the default result has to be written twice)
1070:
1405:-- It works similarly to the template {{yesno}}.
1164:-- Unknown string returns nil, result is false.
108:in use by a very large number of pages, or is
8:
58:This Lua module is used in system messages
1243:-- value is nil or an unrecognized string
1352:Editors can experiment in this module's
1110:-- When value is nil, result is false.
7:
139:, to allow for distinctions between
1856:Modules subject to page protection
469:-- A nil value always returns nil:
14:
855:-- These return "bar":
250:Some input values always return
93:
50:
19:
1:
1081:-only values, use code like:
939:'This is a function.'
840:'This is a function.'
711:'This is a function.'
560:-- These always return false:
370:-- These always return false:
497:-- These always return true:
271:-- These always return true:
200:. Other values evaluate to
1877:
1326:
102:subject to page protection
1837:
1830:
1820:
1813:
1803:
1796:
1771:
1755:
1739:
1723:
1707:
1691:
1675:
1665:
1658:
1633:
1617:
1601:
1585:
1569:
1553:
1537:
1527:
254:, and some always return
84:before implementing them.
76:subpages, or in your own
1508:
1459:
1452:
1445:
1438:
1413:
1409:
1402:
1395:
1392:
1204:
1083:
971:
636:
494:
268:
224:
158:
1385:Subpages of this module
626:Undefined input ('foo')
242:'Module:Yesno'
756:-- These return true:
262:values always return
106:highly visible module
1202:Better suggestions:
965:Handling nil results
639:-- These return nil:
196:always evaluates to
24:Module documentation
625:
1455:-- following line.
1069:To get the binary
634:for these inputs.
120:
119:
88:
87:
1868:
1842:
1841:
1835:
1834:
1828:
1827:
1824:
1818:
1817:
1811:
1810:
1807:
1801:
1800:
1794:
1793:
1790:
1787:
1784:
1781:
1778:
1775:
1769:
1768:
1765:
1762:
1759:
1753:
1752:
1749:
1746:
1743:
1737:
1736:
1733:
1730:
1727:
1721:
1720:
1717:
1714:
1711:
1705:
1704:
1701:
1698:
1695:
1689:
1688:
1685:
1682:
1679:
1673:
1672:
1669:
1663:
1662:
1656:
1655:
1652:
1649:
1646:
1643:
1640:
1637:
1631:
1630:
1627:
1624:
1621:
1615:
1614:
1611:
1608:
1605:
1599:
1598:
1595:
1592:
1589:
1583:
1582:
1579:
1576:
1573:
1567:
1566:
1563:
1560:
1557:
1551:
1550:
1547:
1544:
1541:
1535:
1534:
1531:
1525:
1524:
1521:
1518:
1515:
1512:
1506:
1505:
1502:
1499:
1496:
1493:
1490:
1487:
1484:
1483:'string'
1481:
1478:
1475:
1472:
1469:
1466:
1463:
1457:
1456:
1450:
1449:
1443:
1442:
1436:
1435:
1432:
1429:
1426:
1423:
1420:
1417:
1411:
1407:
1406:
1400:
1399:
1381:
1366:
1350:
1337:Module:Yesno/doc
1322:
1319:
1316:
1313:
1310:
1307:
1304:
1301:
1298:
1295:
1292:
1289:
1286:
1283:
1280:
1277:
1274:
1271:
1268:
1265:
1262:
1259:
1256:
1253:
1250:
1247:
1244:
1241:
1238:
1235:
1232:
1229:
1226:
1223:
1220:
1217:
1214:
1211:
1208:
1198:
1195:
1192:
1189:
1186:
1183:
1180:
1177:
1174:
1171:
1168:
1165:
1162:
1159:
1156:
1153:
1150:
1147:
1144:
1141:
1138:
1135:
1132:
1129:
1126:
1123:
1120:
1117:
1114:
1111:
1108:
1105:
1102:
1099:
1096:
1093:
1090:
1087:
1080:
1079:
1076:
1073:
1065:
1064:-- Returns true.
1062:
1059:
1056:
1053:
1050:
1047:
1044:
1041:
1038:
1035:
1032:
1029:
1026:
1023:
1020:
1017:
1014:
1011:
1008:
1005:
1002:
999:
996:
993:
990:
987:
984:
981:
978:
975:
959:Module:Arguments
952:
949:
946:
943:
940:
937:
934:
931:
928:
925:
922:
919:
916:
913:
910:
907:
904:
901:
898:
895:
892:
889:
886:
883:
880:
877:
874:
871:
868:
865:
862:
859:
856:
853:
850:
847:
844:
841:
838:
835:
832:
829:
826:
823:
820:
817:
814:
811:
808:
805:
802:
799:
796:
793:
790:
787:
784:
781:
778:
775:
772:
769:
766:
763:
760:
757:
754:
751:
748:
745:
742:
739:
736:
733:
730:
727:
724:
721:
718:
715:
712:
709:
706:
703:
700:
697:
694:
691:
688:
685:
682:
679:
676:
673:
670:
667:
664:
661:
658:
655:
652:
649:
646:
643:
640:
633:
621:
618:
615:
612:
609:
606:
603:
600:
597:
594:
591:
588:
585:
582:
579:
576:
573:
570:
567:
564:
561:
558:
555:
552:
549:
546:
543:
540:
537:
534:
531:
528:
525:
522:
519:
516:
513:
510:
507:
504:
501:
498:
488:
485:
482:
479:
476:
473:
470:
467:
464:
461:
458:
455:
452:
449:
446:
443:
440:
437:
434:
431:
428:
425:
422:
419:
416:
413:
410:
407:
404:
401:
398:
395:
392:
389:
386:
383:
380:
377:
374:
371:
368:
365:
362:
359:
356:
353:
350:
347:
344:
341:
338:
335:
332:
329:
326:
323:
320:
317:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
265:
261:
257:
253:
246:
243:
240:
237:
234:
231:
228:
221:
215:
203:
199:
195:
191:
187:
183:
177:
174:
171:
168:
165:
162:
150:
146:
142:
138:
134:
129:
125:
97:
96:
90:
54:
53:
47:
44:
25:
23:
22:
1876:
1875:
1871:
1870:
1869:
1867:
1866:
1865:
1861:Lua metamodules
1846:
1845:
1844:
1843:
1839:
1836:
1832:
1829:
1825:
1822:
1819:
1815:
1812:
1808:
1805:
1802:
1798:
1795:
1791:
1788:
1785:
1782:
1779:
1776:
1773:
1770:
1766:
1763:
1760:
1757:
1754:
1750:
1747:
1744:
1741:
1738:
1735:'false'
1734:
1731:
1728:
1725:
1722:
1718:
1715:
1712:
1709:
1706:
1702:
1699:
1696:
1693:
1690:
1686:
1683:
1680:
1677:
1674:
1670:
1667:
1664:
1660:
1657:
1653:
1650:
1647:
1644:
1641:
1638:
1635:
1632:
1628:
1625:
1622:
1619:
1616:
1612:
1609:
1606:
1603:
1600:
1596:
1593:
1590:
1587:
1584:
1580:
1577:
1574:
1571:
1568:
1564:
1561:
1558:
1555:
1552:
1548:
1545:
1542:
1539:
1536:
1532:
1529:
1526:
1522:
1519:
1516:
1513:
1510:
1507:
1503:
1500:
1497:
1494:
1491:
1488:
1485:
1482:
1479:
1476:
1473:
1470:
1467:
1464:
1461:
1458:
1454:
1451:
1447:
1444:
1440:
1437:
1433:
1430:
1427:
1424:
1421:
1418:
1415:
1412:
1408:
1404:
1401:
1397:
1394:
1389:
1388:
1383:
1371:
1356:
1351:
1340:
1325:
1324:
1323:
1320:
1317:
1314:
1311:
1308:
1305:
1302:
1299:
1296:
1293:
1290:
1287:
1284:
1281:
1278:
1275:
1272:
1269:
1266:
1263:
1260:
1257:
1254:
1251:
1248:
1245:
1242:
1239:
1236:
1233:
1230:
1227:
1224:
1221:
1218:
1215:
1212:
1209:
1206:
1200:
1199:
1196:
1193:
1190:
1187:
1184:
1181:
1178:
1175:
1172:
1169:
1166:
1163:
1160:
1157:
1154:
1151:
1148:
1145:
1142:
1139:
1136:
1133:
1130:
1127:
1124:
1121:
1118:
1115:
1112:
1109:
1106:
1103:
1100:
1097:
1094:
1091:
1088:
1085:
1077:
1074:
1071:
1067:
1066:
1063:
1060:
1057:
1054:
1051:
1048:
1045:
1043:-- Returns nil.
1042:
1039:
1036:
1033:
1030:
1027:
1024:
1022:-- Returns nil.
1021:
1018:
1015:
1012:
1009:
1006:
1003:
1001:-- Returns nil.
1000:
997:
994:
991:
988:
986:-- Returns nil.
985:
982:
979:
976:
973:
969:By definition:
967:
954:
953:
950:
947:
944:
941:
938:
935:
932:
929:
926:
923:
920:
917:
914:
911:
908:
905:
902:
899:
896:
893:
890:
887:
884:
881:
878:
875:
872:
869:
866:
863:
860:
857:
854:
851:
848:
845:
842:
839:
836:
833:
830:
827:
824:
821:
818:
815:
812:
809:
806:
803:
800:
797:
794:
791:
788:
785:
782:
779:
776:
773:
770:
767:
764:
761:
758:
755:
752:
749:
746:
743:
740:
737:
734:
731:
728:
725:
722:
719:
716:
713:
710:
707:
704:
701:
698:
695:
692:
689:
686:
683:
680:
677:
674:
671:
668:
665:
662:
659:
656:
653:
650:
647:
644:
641:
638:
631:
628:
623:
622:
619:
617:'fALsE'
616:
613:
610:
607:
604:
601:
598:
595:
592:
589:
586:
583:
580:
577:
574:
571:
568:
565:
562:
559:
556:
553:
550:
547:
544:
541:
538:
535:
532:
529:
526:
523:
520:
517:
514:
511:
508:
505:
502:
499:
496:
490:
489:
486:
483:
480:
477:
474:
471:
468:
465:
462:
459:
456:
453:
450:
447:
444:
441:
438:
435:
432:
429:
426:
423:
420:
417:
414:
411:
408:
405:
403:'false'
402:
399:
396:
393:
390:
387:
384:
381:
378:
375:
372:
369:
366:
363:
360:
357:
354:
351:
348:
345:
342:
339:
336:
333:
330:
327:
324:
321:
318:
315:
312:
309:
306:
303:
300:
297:
294:
291:
288:
285:
282:
279:
276:
273:
270:
263:
259:
255:
251:
248:
247:
244:
241:
238:
235:
232:
229:
226:
219:
213:
210:
201:
197:
193:
189:
185:
181:
179:
178:
175:
172:
169:
166:
163:
160:
157:
148:
144:
140:
136:
132:
127:
123:
100:This module is
94:
67:
65:
51:
45:
26:
20:
18:
12:
11:
5:
1874:
1872:
1864:
1863:
1858:
1848:
1847:
1597:'true'
1393:
1205:
1084:
972:
966:
963:
637:
627:
624:
554:'tRuE'
495:
304:'true'
269:
225:
209:
206:
159:
156:
153:
118:
117:
98:
86:
85:
78:module sandbox
55:
17:
16:
13:
10:
9:
6:
4:
3:
2:
1873:
1862:
1859:
1857:
1854:
1853:
1851:
1838:
1831:
1821:
1814:
1804:
1797:
1772:
1767:'off'
1756:
1740:
1724:
1708:
1692:
1676:
1666:
1659:
1634:
1618:
1602:
1586:
1570:
1565:'yes'
1554:
1538:
1528:
1509:
1460:
1453:
1446:
1439:
1414:
1410:
1403:
1396:
1391:
1386:
1379:
1375:
1370:
1364:
1360:
1355:
1348:
1344:
1338:
1334:
1330:
1329:documentation
1203:
1179:'foo'
1152:'foo'
1082:
1052:'foo'
995:'foo'
970:
964:
962:
960:
948:'bar'
918:'bar'
900:'bar'
882:'bar'
870:'bar'
864:'foo'
765:'foo'
750:'bar'
660:'foo'
635:
530:'yEs'
518:'YES'
506:'Yes'
493:
427:'off'
280:'yes'
267:
223:
218:
207:
205:
154:
152:
116:from editing.
115:
111:
107:
103:
99:
92:
91:
83:
79:
75:
71:
63:
59:
56:
49:
48:
42:
38:
34:
30:
1703:'no'
1629:'on'
1390:
1201:
1068:
968:
955:
629:
593:'nO'
581:'NO'
569:'No'
491:
379:'no'
328:'on'
249:
220:}}
214:{{
211:
180:
121:
57:
1751:'f'
1719:'n'
1613:'t'
1581:'y'
1333:transcluded
605:'N'
542:'Y'
439:'0'
415:'f'
391:'n'
340:'1'
316:'t'
292:'y'
110:substituted
39:] [
35:] [
31:] [
1850:Categories
1327:The above
1297:myvariable
1285:myvariable
1267:myvariable
1246:myvariable
1231:myvariable
1210:myvariable
1167:myvariable
1140:myvariable
1113:myvariable
1086:myvariable
912:''
813:''
690:''
135:values as
104:. It is a
74:/testcases
1369:testcases
222:instead.
114:protected
82:talk page
60:, and on
1777:tonumber
1639:tonumber
1419:function
930:function
831:function
702:function
70:/sandbox
1826:default
1431:default
1376:|
1361:|
1354:sandbox
1347:history
1345:|
236:require
202:default
173:default
37:history
1823:return
1806:return
1678:elseif
1668:return
1540:elseif
1530:return
1416:return
1382:pages.
936:return
837:return
708:return
192:, and
155:Syntax
1809:false
1687:false
1495:lower
1335:from
1309:value
1303:yesno
1273:value
1264:local
1222:value
1216:yesno
1207:local
1194:false
1173:yesno
1161:false
1146:yesno
1125:value
1119:yesno
1104:false
1098:value
1092:yesno
1078:false
1046:yesno
1037:false
1025:yesno
1004:yesno
989:yesno
974:yesno
924:yesno
906:yesno
888:yesno
876:yesno
858:yesno
825:yesno
807:yesno
789:yesno
777:yesno
759:yesno
738:yesno
720:yesno
696:yesno
684:yesno
672:yesno
666:yesno
654:yesno
642:yesno
611:yesno
599:yesno
587:yesno
575:yesno
563:yesno
548:yesno
536:yesno
524:yesno
512:yesno
500:yesno
484:yesno
472:yesno
463:false
457:yesno
445:yesno
433:yesno
421:yesno
409:yesno
397:yesno
385:yesno
373:yesno
358:yesno
346:yesno
334:yesno
322:yesno
310:yesno
298:yesno
286:yesno
274:yesno
256:false
230:yesno
227:local
217:yesno
208:Usage
190:false
182:value
167:value
161:yesno
145:false
128:false
43:]
41:purge
27:[
1816:else
1799:then
1671:true
1661:then
1549:true
1523:then
1468:type
1374:edit
1367:and
1363:diff
1359:edit
1343:edit
1315:true
1294:else
1291:true
1282:then
1252:true
1240:then
1185:true
1131:true
1072:true
1058:true
1016:true
879:({},
849:true
819:true
801:true
783:true
780:({},
771:true
732:true
669:({})
364:true
252:true
186:true
143:and
126:and
124:true
33:edit
29:view
1840:end
1833:end
1783:val
1761:val
1745:val
1729:val
1713:val
1697:val
1681:val
1645:val
1623:val
1607:val
1591:val
1575:val
1559:val
1543:val
1533:nil
1520:nil
1514:val
1504:val
1489:val
1486:and
1474:val
1462:val
1425:val
1378:run
1331:is
1321:end
1279:nil
1255:end
1237:nil
1031:nil
1010:nil
980:nil
942:end
843:end
744:nil
726:nil
714:end
648:nil
632:nil
478:nil
264:nil
260:nil
198:nil
194:nil
188:or
149:nil
141:nil
137:nil
133:nil
72:or
1852::
1789:==
1774:or
1764:==
1758:or
1748:==
1742:or
1732:==
1726:or
1716:==
1710:or
1700:==
1694:or
1684:==
1651:==
1636:or
1626:==
1620:or
1610:==
1604:or
1594:==
1588:or
1578:==
1572:or
1562:==
1556:or
1546:==
1517:==
1511:if
1501:or
1498:()
1480:==
1339:.
1276:==
1270:if
1234:==
1228:if
1191:or
1158:or
1128:or
1101:or
961:.
933:()
834:()
705:()
487:()
266:.
258:.
204:.
1792:0
1786:)
1780:(
1654:1
1648:)
1642:(
1492::
1477:)
1471:(
1465:=
1434:)
1428:,
1422:(
1387:.
1380:)
1372:(
1365:)
1357:(
1349:)
1341:(
1318:)
1312:,
1306:(
1300:=
1288:=
1249:=
1225:)
1219:(
1213:=
1188:)
1182:,
1176:(
1170:=
1155:)
1149:(
1143:=
1134:)
1122:(
1116:=
1107:)
1095:(
1089:=
1075:/
1061:)
1055:,
1049:(
1040:)
1034:,
1028:(
1019:)
1013:,
1007:(
998:)
992:(
983:)
977:(
951:)
945:,
927:(
921:)
915:,
909:(
903:)
897:,
894:5
891:(
885:)
873:)
867:,
861:(
852:)
846:,
828:(
822:)
816:,
810:(
804:)
798:,
795:5
792:(
786:)
774:)
768:,
762:(
753:)
747:,
741:(
735:)
729:,
723:(
717:)
699:(
693:)
687:(
681:)
678:5
675:(
663:)
657:(
651:)
645:(
620:)
614:(
608:)
602:(
596:)
590:(
584:)
578:(
572:)
566:(
557:)
551:(
545:)
539:(
533:)
527:(
521:)
515:(
509:)
503:(
481:)
475:(
466:)
460:(
454:)
451:0
448:(
442:)
436:(
430:)
424:(
418:)
412:(
406:)
400:(
394:)
388:(
382:)
376:(
367:)
361:(
355:)
352:1
349:(
343:)
337:(
331:)
325:(
319:)
313:(
307:)
301:(
295:)
289:(
283:)
277:(
245:)
239:(
233:=
176:)
170:,
164:(
64:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.