diff options
| author | ivar <i@oiee.no> | 2025-12-04 23:30:39 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2025-12-04 23:30:39 +0100 |
| commit | 8c355b82df02bc650c5ba101d838121f485e8581 (patch) | |
| tree | 00ff527de5968d7899f7f653355073b8a416328b /api/WhatApi/Templates/TemplateFulfiller.cs | |
| parent | deade767eace22a8c5281dcd5360c300395e2b5e (diff) | |
| download | what-8c355b82df02bc650c5ba101d838121f485e8581.tar.xz what-8c355b82df02bc650c5ba101d838121f485e8581.zip | |
Diffstat (limited to 'api/WhatApi/Templates/TemplateFulfiller.cs')
| -rw-r--r-- | api/WhatApi/Templates/TemplateFulfiller.cs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/api/WhatApi/Templates/TemplateFulfiller.cs b/api/WhatApi/Templates/TemplateFulfiller.cs index 3433701..e24e77d 100644 --- a/api/WhatApi/Templates/TemplateFulfiller.cs +++ b/api/WhatApi/Templates/TemplateFulfiller.cs @@ -5,25 +5,37 @@ namespace WhatApi.Templates; public class TemplateFulfiller { private static readonly FluidParser Parser = new(); + private static readonly TemplateContext EmptyContext = 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")); private static string WebLoginTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_login.liquid")); + private static string WebTermsTemplate => File.ReadAllText(Path.Combine(TemplateDirectory, "web_terms.liquid")); - public static string WebMapPage(object? data = null) { + + public static string WebMapPage() { Parser.TryParse(WebMapTemplate, out var template); - var context = data is null ? new TemplateContext() : new TemplateContext(data); - return template.Render(context); + return template.Render(EmptyContext); } - public static string WebUploadPage(object? data = null) { + public static string WebUploadPage() { Parser.TryParse(WebUploadTemplate, out var template); - var context = data is null ? new TemplateContext() : new TemplateContext(data); - return template.Render(context); + return template.Render(EmptyContext); + } + + public class WebLoginModel + { + public string Error { get; set; } = string.Empty; } - public static string WebLoginPage(object? data = null) { + + public static string WebLoginPage(WebLoginModel model) { Parser.TryParse(WebLoginTemplate, out var template); - var context = data is null ? new TemplateContext() : new TemplateContext(data); + var context = new TemplateContext(model); return template.Render(context); } + + public static string WebTermsPage() { + Parser.TryParse(WebTermsTemplate, out var template); + return template.Render(EmptyContext); + } }
\ No newline at end of file |
