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); } }