public static $assets_version = false
If set, add the specified value as a ?v=' to the end of scripts and stylesheets
that use a relative absolute path and end in
.jsor
.css` such as:
/apps/myapp/js/myscript.js -> /apps/myapp/js/myscript.js?v=123
/apps/myapp/css/style.css -> /apps/myapp/css/style.css?v=123
Should not affect scripts or stylesheets of these forms:
<script>...</script>
<link rel="stylesheet" href="..." />
https://www.google.com/script.js
//www.google.com/script.js?abc=123
This prevents it from altering external links including protocol-relative links, and links which are being passed parameters already.
public static $bypass_layout = false
Set this to true if you wish to globally bypass all templates. Primarily used by the async utility.
public $head = ''
Data to place in the <head>
of the document. To use,
add the following tag to your layouts:
{{ head|none }}
public $tail = ''
Data to place just before the closing </body>
tag.
To use, add the following tag to your layouts:
{{ tail|none }}
public $title = ''
The title of the page. To use, add something like this to your layouts:
{% if title %}<h1>{{ title }}</h1>{% end %}
public $body = ''
The main body of the page. To use, add the following tag to your layouts:
{{ body|none }}
public $is_being_rendered = false
This is set to true when the template is currently rendering the page.
public render ($tpl, $controller)
Render the page in its template and layout. Uses a Template object for rendering. Determines whether to render with a layout template at all, and if so, which one. Also determines whether to render as a preview or as a real page.
public add_script ($script, $add_to = 'head', $type = '', $integrity = '', $crossorigin = '')
Add a script to the head or tail of a page, or echo immediately if the template rendering has already begun. Tracks duplicate additions so scripts will only be added once. This makes it a good replacement for adding script include tags to view templates.
public add_style ($script, $add_to = 'head', $type = '', $integrity = '', $crossorigin = '')
Add a style to the page. Simply an alias of add_script()
for the sake of
referring to stylesheets correctly as styles and not scripts, but functionally
they both do the same thing, and add_script()
always handled stylesheets
as well.
public add_meta ($name, $content = '', $attr = 'name')
Add a meta tag to the page. Example usage:
$page->add_meta ('keywords', 'One, Two, Three');
$page->add_meta ('UTF-8', '', 'charset');
$page->add_meta ('og:image', 'http://example.com/foo.jpg', 'property');
$page->add_meta ('refresh', '30;url=http://example.com/', 'http-equiv');
$page->add_meta ('<meta charset="utf-8" />');
Basic document object used to contain the elements sent to the layout template for rendering. You can add any values you want to the object to shape your page output.
The layout property sets which template should be used to render the design of the page, unless you specify:
This will skip the layout and simply return the page body to the user.
The convention is to use the body property for the main body content.