Render reference
The properties of opt and the next function of exports.render.
On this page
exports.render(opt, next) receives the instance and the request in opt, and gives back the content with next:
exports.render = function(opt, next) {
next('<b>' + opt.config.name.encode() + '</b>');
};The entries of type property are properties of opt.
API
property
opt.config
The configuration of the instance.
opt.configReturns Object
The values saved by the settings form. An instance saved before you added a key to exports.config does not have that key.
property
opt.html
The inner HTML of the instance, as saved in the page.
opt.htmlReturns String
It still holds the CMS_ classes of the editor.
property
opt.body
The whole instance with its wrapper, cleaned for the public page.
opt.bodyReturns String
property
opt.template
The <template> section of the widget.
opt.templateReturns String
CLASS is already replaced. It is undefined when the widget has no template.
property
opt.id
The identifier of the instance.
opt.idReturns String
The value of data-cms-id.
property
opt.widget
The identifier of the widget.
opt.widgetReturns String
property
opt.url
The address of the page, such as /about-us/.
opt.urlReturns String
property
opt.page
The page that is being built.
opt.pageReturns Object
Its properties include id, name, title, description, keywords, url, language, layoutid and parentid.
property
opt.vars
The variables of the site, as keys and values.
opt.varsReturns Object
property
opt.breadcrumb
The path from the top page to the current page.
opt.breadcrumbReturns Array
An array of pages with id, url, name, title, icon and language. The first has first: true and the last has last: true.
property
opt.mobile
true when the visitor uses a mobile device.
opt.mobileReturns Boolean
property
opt.robot
true when the visitor is a search engine robot.
opt.robotReturns Boolean
property
opt.ua
The parsed user agent of the visitor.
opt.uaReturns Object
An object with os, browser and device.
property
opt.user
The user of the request.
opt.userReturns Object
It is undefined for anonymous visitors.
property
opt.controller
The Total.js controller of the request.
opt.controllerReturns Object
Use it to read headers, the query or cookies of the request.
method
next(content, [replace], [cache])
Gives CMS the content of the instance.
next(content, [replace], [cache])| Parameter | Type | Description |
|---|---|---|
content |
String |
The HTML of the instance. |
replace? |
Boolean |
true replaces the wrapper too. An empty content then removes the instance. Default: false |
cache? |
Boolean |
true keeps the result until CMS builds the page again. Default: false |
Call it once, also when something fails. Without replace, the content goes inside the wrapper of the instance.
exports.render = function(opt, next) {
next('<ui-import config="url:{0}"></ui-import>'.format(opt.config.url), true, true);
};