diff options
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 |
