HtmlDocument guide
Last updated
Last updated
When you're using Cherrycake to build a web app, the module helps you create standard HTML structure headers and footers with some additional useful capabilities.
The two most important methods of the module are and , 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:
This would output the following HTML code:
For example, take a look at this HTML pattern named home.html
:
And we get exactly the same "Hello World!" HTML page as above.
Take a look at the, where you can configure the title of your page, description, keywords, and many other important aspects of your HTML document structure.
See how HtmlDocument also took care of including a CSS stylesheet and a JavaScript script automatically. This will come in handy when you start using the .
You might find quite helpful to use the and methods in your HTML . Just call them at the beginning and at the end of your pattern and you'll get a complete HTML document.
Now we parse it and send it to the user's browser with :
Remembers to add the module to your module's list of dependent core modules so it is available to use, like this: