From 83f51dc11b70b3f5e33cf89223d3ff26117f107e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:52:28 +0000 Subject: [PATCH 1/4] Initial plan From b3ceaf096e6d80fd76dead9f4df7388e0e913012 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:57:56 +0000 Subject: [PATCH 2/4] Enhance Handlebars example with multi-file templates and comprehensive HTML structure Co-authored-by: Thomas-Torggler-EOS <163338087+Thomas-Torggler-EOS@users.noreply.github.com> --- .../Handlebars/HandleBars.Codeunit.al | 164 ++++++++++++++++++ EX004.EosAdminLib/Handlebars/README.md | 74 ++++++++ .../Handlebars/templates/example-output.html | 56 ++++++ .../Handlebars/templates/footer.html | 5 + .../Handlebars/templates/header.html | 6 + .../Handlebars/templates/layout.html | 25 +++ .../Handlebars/templates/order-details.html | 18 ++ 7 files changed, 348 insertions(+) create mode 100644 EX004.EosAdminLib/Handlebars/README.md create mode 100644 EX004.EosAdminLib/Handlebars/templates/example-output.html create mode 100644 EX004.EosAdminLib/Handlebars/templates/footer.html create mode 100644 EX004.EosAdminLib/Handlebars/templates/header.html create mode 100644 EX004.EosAdminLib/Handlebars/templates/layout.html create mode 100644 EX004.EosAdminLib/Handlebars/templates/order-details.html diff --git a/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al b/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al index 2d24a25..285dd77 100644 --- a/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al +++ b/EX004.EosAdminLib/Handlebars/HandleBars.Codeunit.al @@ -80,6 +80,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('