Skip to content

Commit a24adbd

Browse files
committed
feat(1627): fix template render by providing length function
Signed-off-by: mmyslblocky <michal.myslinski@blockydevs.com>
1 parent 7cd3490 commit a24adbd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/core/errors/network-error.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { CliError } from './cli-error';
22

3-
export const DEFAULT_TEMPLATE = '{{{message}}}';
4-
53
export class NetworkError extends CliError {
64
private static readonly CODE = 'NETWORK_ERROR';
75
private static readonly TEMPLATE = `
8-
{{{message}}}\n
9-
{{#if context.apiMessages}}{{#if (gt (length context.apiMessages) 0)}}
10-
Detailed message:\n
11-
{{#each context.apiMessages}}
12-
• {{this}}\n{{/each}}
13-
{{/if}}{{/if}}
14-
`.trim();
6+
{{message}}
7+
{{#if context.apiMessages}}{{#if (gt (length context.apiMessages) 0)}}
8+
Detailed error message:
9+
{{#each context.apiMessages}}
10+
• {{this}}{{/each}}
11+
{{/if}}{{/if}}
12+
`.trim();
1513

1614
constructor(
1715
message: string,

src/core/services/output/strategies/template-output-strategy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export class TemplateOutputStrategy implements OutputFormatterStrategy {
7878
return value + 1;
7979
});
8080

81+
// Helper for array/string length
82+
Handlebars.registerHelper('length', function (value: unknown) {
83+
if (Array.isArray(value)) return value.length;
84+
if (typeof value === 'string') return value.length;
85+
return 0;
86+
});
87+
8188
// Helper for conditional rendering
8289
Handlebars.registerHelper(
8390
'if_eq',

0 commit comments

Comments
 (0)