summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Templates/TemplateFulfiller.cs
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-02 22:38:23 +0100
committerivar <i@oiee.no>2025-12-02 22:38:23 +0100
commit68ffad06a6cfd2cd2015ab03fb82bf69629dd7ec (patch)
treeefab90e59deae00953704059efdec14cb3ad81c7 /api/WhatApi/Templates/TemplateFulfiller.cs
parentd2089c0038460504869b27203143e40441a86eff (diff)
downloadwhat-68ffad06a6cfd2cd2015ab03fb82bf69629dd7ec.tar.xz
what-68ffad06a6cfd2cd2015ab03fb82bf69629dd7ec.zip
Move off razor pages
Diffstat (limited to 'api/WhatApi/Templates/TemplateFulfiller.cs')
-rw-r--r--api/WhatApi/Templates/TemplateFulfiller.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/api/WhatApi/Templates/TemplateFulfiller.cs b/api/WhatApi/Templates/TemplateFulfiller.cs
new file mode 100644
index 0000000..19d3bde
--- /dev/null
+++ b/api/WhatApi/Templates/TemplateFulfiller.cs
@@ -0,0 +1,23 @@
+using Fluid;
+
+namespace WhatApi.Templates;
+
+public class TemplateFulfiller
+{
+ private static readonly FluidParser Parser = new();
+ private static readonly string TemplateDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Templates");
+ private static string WebMapTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_map.liquid"));
+ private static string WebUploadTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_upload.liquid"));
+
+ public static string WebMapPage(object? data = null) {
+ Parser.TryParse(WebMapTemplate, out var template);
+ var context = data is null ? new TemplateContext() : new TemplateContext(data);
+ return template.Render(context);
+ }
+
+ public static string WebUploadPage(object? data = null) {
+ Parser.TryParse(WebUploadTemplate, out var template);
+ var context = data is null ? new TemplateContext() : new TemplateContext(data);
+ return template.Render(context);
+ }
+} \ No newline at end of file