Skip to content

Commit

Permalink
Added a way to customize the doctype declaration the html tag and the…
Browse files Browse the repository at this point in the history
… body tag to WebServerRequest.
  • Loading branch information
Relintai committed Jul 24, 2023
1 parent f28b6c0 commit b4fe2b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/web/doc_classes/WebServerRequest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
10 changes: 5 additions & 5 deletions modules/web/http/web_server_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b4fe2b0

Please sign in to comment.