diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 540f74c..5445e51 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -34,24 +34,9 @@ namespace Ooui public static byte[] ClientJsBytes => clientJsBytes; public static string ClientJsEtag => clientJsEtag; - public static string Template { get; set; } = $@" - - - @Title - - - - - - -
-@InitialHtml -
- - - - -"; + public static string HeadHtml { get; set; } = @""; + public static string BodyHeaderHtml { get; set; } = @""; + public static string BodyFooterHtml { get; set; } = @""; static string host = "*"; public static string Host { @@ -392,7 +377,40 @@ namespace Ooui public static string RenderTemplate (string webSocketPath, string title = "", string initialHtml = "") { - return Template.Replace ("@WebSocketPath", webSocketPath).Replace ("@Styles", rules.ToString ()).Replace ("@Title", title).Replace ("@InitialHtml", initialHtml); + using (var w = new System.IO.StringWriter ()) { + RenderTemplate (w, webSocketPath, title, initialHtml); + return w.ToString (); + } + } + + public static void RenderTemplate (TextWriter writer, string webSocketPath, string title, string initialHtml) + { + writer.Write (@" + + + "); + writer.Write (title.Replace ("&", "&").Replace ("<", "<")); + writer.Write (@" + + "); + writer.WriteLine (HeadHtml); + writer.WriteLine (@" + +"); + writer.WriteLine (BodyHeaderHtml); + writer.WriteLine (@"
"); + writer.WriteLine (initialHtml); + writer.Write (@"
+ + +"); + writer.WriteLine (BodyFooterHtml); + writer.WriteLine (@" +"); } class DataHandler : RequestHandler