11using System . Text . Json ;
22
33using HandlebarsDotNet ;
4+ using HandlebarsDotNet . Helpers ;
45using HandlebarsDotNet . IO ;
56
67using Humanizer ;
@@ -11,21 +12,24 @@ namespace Generators;
1112
1213internal static class TemplateRenderer
1314{
15+ private static readonly IHandlebars HandlebarsContext = Handlebars . Create ( ) ;
16+
1417 static TemplateRenderer ( )
1518 {
16- Handlebars . RegisterHelper ( "method_name" , ( writer , context , parameters ) =>
19+ HandlebarsHelpers . Register ( HandlebarsContext ) ;
20+ HandlebarsContext . RegisterHelper ( "method_name" , ( writer , context , parameters ) =>
1721 {
1822 var path = parameters . SelectMany ( parameter => parameter as IEnumerable < string > ?? [ parameter . ToString ( ) ! ] ) ;
1923 writer . WriteSafeString ( string . Join ( " " , path ) . Dehumanize ( ) ) ;
2024 } ) ;
21- Handlebars . Configuration . FormatterProviders . Add ( new JsonElementFormatter ( ) ) ;
25+ HandlebarsContext . Configuration . FormatterProviders . Add ( new JsonElementFormatter ( ) ) ;
2226 }
2327
2428 public static string RenderTests ( Exercise exercise , TestCase [ ] testCases ) =>
2529 CompileTemplate ( exercise ) ( ToTemplateData ( exercise , testCases ) ) ;
2630
2731 private static HandlebarsTemplate < object , object > CompileTemplate ( Exercise exercise ) =>
28- Handlebars . Compile ( File . ReadAllText ( Paths . TemplateFile ( exercise ) ) ) ;
32+ HandlebarsContext . Compile ( File . ReadAllText ( Paths . TemplateFile ( exercise ) ) ) ;
2933
3034 private static Dictionary < string , object > ToTemplateData ( Exercise exercise , TestCase [ ] testCases ) =>
3135 new ( )
0 commit comments