Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 2x 2x 29x 14x 14x 3x 11x 11x 23x 11x | import { HandlebarsHelper, HelperConstructorBlock } from "./helper";
export const repeatHelper: HelperConstructorBlock = (ctx) => {
return new HandlebarsHelper("repeat", function (rawNum, options) {
const num = Number.parseInt(rawNum);
if (Number.isNaN(num)) {
throw new Error(`Can't convert "${rawNum}" to number while using repeat`);
}
let ret = "";
for (let i = 0; i < rawNum; i++) {
ret += options.fn({ ...this, "repeat_index": i });
}
return ret;
});
};
|