1. A computer-implemented method for generating a valid HTML document, comprising: providing an abstract syntax tree, the abstract syntax tree including a plurality of nodes, each node in the plurality of nodes representing an element in a template file, in response to receiving a request on a web server for a webpage; traversing the abstract syntax tree; for each node in the abstract syntax tree: determining a type of the node; and performing an action based on the determined node type using one or more compiled template objects generated from one or more templates in the template file; generating the valid HTML document based on the plurality of actions determined by traversing the abstract syntax tree on the web server, to send to display the webpage on a browser, wherein the valid HTML document is type-defined; and sending the valid HTML document for display on the browser.