Fix apv2, WIP

This commit is contained in:
2026-06-06 22:37:29 +02:00
parent c571e6a209
commit c23de0ea66
37 changed files with 199 additions and 118 deletions
+6 -17
View File
@@ -90,22 +90,9 @@ export const registerHandlebarsHelpers = function () {
return str.toLowerCase();
});
Handlebars.registerHelper('romanNumber', function (numb) {
switch (numb) {
case 0:
return '';
case 1:
return 'I';
case 2:
return 'II';
case 3:
return 'III';
case 4:
return 'IV';
case 5:
return 'V';
default:
throw new Error('Le handicap rareté doit être comprise entre 0 et 5');
}
const n = Number(numb);
if ( !Number.isFinite(n) || n < 0 ) return '';
return ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'][n] ?? '';
});
// search translation with variables
@@ -386,7 +373,9 @@ export const registerHandlebarsHelpers = function () {
Handlebars.registerHelper('repeat', function (times, start, indexLabel, block) {
var accum = '';
if (!indexLabel) { indexLabel = "index" }
if (!start) { start = 0; }
times = Number(times);
start = Number(start ?? 0);
if ( !Number.isFinite(times) || !Number.isFinite(start) || times < 0 ) return '';
for (var i = start; i < times + start; ++i) {
block.data[indexLabel] = i;
block.data.first = i === start;