When you're using Cherrycake to build a web app, the HtmlDocument module helps you create standard HTML structure headers and footers with some additional useful capabilities.
The two most important methods of the HtmlDocument module are HtmlDocument::header and HtmlDocument::footer, they both take care of building the usual <html><body> ... and ...</body></html> tags. For example, take this code that outputs a simple HTML response to show a webpage:
Take a look at the configuration of the HtmlDocument, where you can configure the title of your page, description, keywords, and many other important aspects of your HTML document structure.
Common usage with Patterns
You might find quite helpful to use the header and footerHtmlDocument methods in your HTML patterns. Just call them at the beginning and at the end of your pattern and you'll get a complete HTML document.
For example, take a look at this HTML pattern named home.html:
<?= $e->HtmlDocument->header() ?>
<?= $e->HtmlDocument->footer() ?>
Now we parse it and send it to the user's browser with Patterns::out:
And we get exactly the same "Hello World!" HTML page as above.
Remembers to add the HtmlDocument module to your module's list of dependent core modules so it is available to use, like this: