Added a way to customize the doctype declaration the html tag and the body tag to WebServerRequest.

This commit is contained in:
Relintai 2023-07-24 17:37:34 +02:00
parent f28b6c0c07
commit b4fe2b0d38
2 changed files with 6 additions and 5 deletions

View File

@ -46,6 +46,7 @@
<return type="void" />
<description>
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].
</description>
</method>
<method name="custom_response_header_get">

View File

@ -267,17 +267,17 @@ void WebServerRequest::compile_body() {
//compiled_body.ensure_capacity(body.size() + head.size() + 15 + 13 + 14 + 15 + 1);
// 15
compiled_body += "<!DOCTYPE html>";
compiled_body += String(get_meta("compiled_body_doctype_override", String("<!DOCTYPE html>")));
// 13
compiled_body += "<html>"
"<head>";
compiled_body += String(get_meta("compiled_body_html_tag_override", String("<html>")));
compiled_body += "<head>";
compiled_body += head;
// 14
compiled_body += "</head>"
"<body>";
compiled_body += "</head>";
compiled_body += String(get_meta("compiled_body_body_tag_override", String("<body>")));
compiled_body += body;
compiled_body += footer;