You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

Page Rendering

Structr doesn’t store pages as simple text files but rather as connected nodes in the database that make up the DOM tree.

Together with the page elements (tags), there’s a lot of metadata like conditional attributes, access rights and visibility settings stored in the database which are difficult to export to a single source file. Furthermore, there are resource files like CSS, JavaScript or images linked to some elements like <a>, <link>, <script>, <image> etc., and they are also connected in the underlying graph database and managed by Structr.

When rendering a page, the page engine starts by looking for a page matching the name or the page’s path attribute. If found, Structr starts a traversal along specific relationships between the page and its elements.

For each node, the metadata are being evaluated to decide whether or not to include a node in the rendering or skip it.

While running through the page graph, the engine collects the data from each node and appends it to the output buffer which gets pushed to the browser client. By pushing the output to the client asynchronously, the browser can start displaying a page even before the server-side rendering has not finished.

The page traversal is very fast. A typical page is created in less than 100 ms on the server.

Search results for "Page Rendering"

Rendering Engine

When a user accesses the URL of a page with their browser, a process is started that runs through this tree structure from top to bottom and generates the HTML representation for each element. This process is called page rendering. Because of this sequential processing, it is possible to run through the same element more than once without additional effort (e.g. for each result of a database query) or to hide the content of specific elements depending on certain conditions (for access control). Together with the template and scripting language available in Structr, this creates an intuitive and extremely flexible rendering engine.

Data Binding

The Page Rendering Engine allows developers to create dynamic markup elements by binding a scripting expression or database query to an element in the markup tree. A dynamic markup element is called a repeater. It is rendered to the output stream once for each object in the query or function result collection and will be displayed including its substructure. The current element can be accessed through a keyword, the so-called data key. The data key is valid in the entire subtree within the repeater element and can also be referenced in content nodes, templates or element attributes.

Visibility

For HTML elements, Structr offers two additional ways to control the visibility during page rendering: showConditions and hideConditions. Both can contain a StructrScript or Javascript expression and - if they are filled - are evaluated before rendering. Depending on the return value of the script, the current element and its substructure will be displayed or hidden. Both fields are auto-script environments, i.e. the text in those fields is interpreted as a script without the need for the template expression markers ${...}.

HTTP Settings

Enables pretty-printing of HTML output produced by the Page Rendering Engine. It can be disabled to reduce bandwith usage.