From b4fe2b0d38e283f2da516701923075455e9dad24 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 24 Jul 2023 17:37:34 +0200 Subject: [PATCH] Added a way to customize the doctype declaration the html tag and the body tag to WebServerRequest. --- modules/web/doc_classes/WebServerRequest.xml | 1 + modules/web/http/web_server_request.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/web/doc_classes/WebServerRequest.xml b/modules/web/doc_classes/WebServerRequest.xml index ae604e25aa..beda9dd846 100644 --- a/modules/web/doc_classes/WebServerRequest.xml +++ b/modules/web/doc_classes/WebServerRequest.xml @@ -46,6 +46,7 @@ Takes the head, body and footer properties, and merges them into the [code]compiled_body[/code] property. It adds an html5 type declaration, then the opening [code]html[/code] tag, then the contents of the [code]head[/code] property to the [code]head[/code] section of the response, and then the contents of the [code]body[/code] then footer property into the [code]body[/code] section of the response, then it closes the main [code]html[/code] tag. + Note: You can override the default doctype declaration by setting the [code]"compiled_body_doctype_override"[/code] meta, the [code]html[/code] tag by setting the [code]"compiled_body_html_tag_override"[/code] meta, and the [code]body[/code] tag by setting the [code]"compiled_body_body_tag_override"[/code] meta using [code]set_meta()[/code]. diff --git a/modules/web/http/web_server_request.cpp b/modules/web/http/web_server_request.cpp index bbb9f97671..721ea8b1d1 100644 --- a/modules/web/http/web_server_request.cpp +++ b/modules/web/http/web_server_request.cpp @@ -267,17 +267,17 @@ void WebServerRequest::compile_body() { //compiled_body.ensure_capacity(body.size() + head.size() + 15 + 13 + 14 + 15 + 1); // 15 - compiled_body += ""; + compiled_body += String(get_meta("compiled_body_doctype_override", String(""))); // 13 - compiled_body += "" - ""; + compiled_body += String(get_meta("compiled_body_html_tag_override", String(""))); + compiled_body += ""; compiled_body += head; // 14 - compiled_body += "" - ""; + compiled_body += ""; + compiled_body += String(get_meta("compiled_body_body_tag_override", String(""))); compiled_body += body; compiled_body += footer;