diff --git a/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al b/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al index 2d24a25..a317b02 100644 --- a/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al +++ b/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al @@ -15,7 +15,6 @@ codeunit 50100 HandlebarsTest Handlebars: Codeunit "EOS004 Handlebars Renderer"; Result: Text; Template: TextBuilder; - Compr: Codeunit "Data Compression"; Payload: JsonObject; begin // initialize the codeunit with a default service config 'TEST' @@ -47,7 +46,6 @@ codeunit 50100 HandlebarsTest Result: Text; Template: TextBuilder; HeaderPartial, LinePartial : TextBuilder; - Compr: Codeunit "Data Compression"; Payload: JsonObject; begin // initialize the codeunit with a default service config 'TEST' @@ -80,6 +78,44 @@ codeunit 50100 HandlebarsTest Assert.IsTrue(Result.Contains('

Hello ' + jh.GetText(Payload, 'CustomerName') + '!

'), ''); end; + [Test] + procedure RenderFromMultiFileTemplate() + var + Handlebars: Codeunit "EOS004 Handlebars Renderer"; + Result: Text; + MainTemplate: TextBuilder; + Payload: JsonObject; + begin + // initialize the codeunit with a default service config 'TEST' + ServiceConfig.Get(ServiceConfigCode); + Handlebars.Initialize(ServiceConfig); + + // Load and set multiple template files as partials + // In a real scenario, these would be loaded from actual files + // Here we simulate loading from the template files we created + Handlebars.SetPartial('header', GetHeaderTemplate()); + Handlebars.SetPartial('order-details', GetOrderDetailsTemplate()); + Handlebars.SetPartial('footer', GetFooterTemplate()); + + // Load the main layout template + MainTemplate.Append(GetLayoutTemplate()); + + // create the payload with more comprehensive data + Payload := CreateEnhancedPayload(); + + // render the complete HTML document + Handlebars.Template(MainTemplate.ToText()); + Handlebars.Render(Payload, Result); + + // validate the multi-file template rendered correctly + Assert.IsTrue(Result.Contains(''), 'Layout template should contain DOCTYPE'); + Assert.IsTrue(Result.Contains('
'), 'Header partial should be included'); + Assert.IsTrue(Result.Contains('
'), 'Order details partial should be included'); + Assert.IsTrue(Result.Contains('