Spanish Total.js
English
Documentation For AI agents
Contents

CMS compiler

Compile pages made with the Total.js CMS editor and render them with their widgets.

.md GitHub

F.TCMS compiles pages made with the Total.js CMS editor. A page is HTML where every widget is an element with data-cms="<widgetid>__<config>". F.TCMS.compile(html, widgets) prepares the page once, and render() makes the HTML for each request: it calls render(opt, next) of every widget and fills the navigation templates.

var widgets = [{
    id: 'hello',
    css: '.hello { color: red; }',
    render: function(opt, next) {
        next('<b>Hello ' + opt.config.name + '</b>');
    }
}];

var page = F.TCMS.compile(html, widgets);
page.importcss();

var output = await page.render({
    url: '/about/',
    navigation: function(id) {
        return [{ url: '/', name: 'Home' }];
    }
});

A <script type="text/navigation" id="main"> in the page is a Tangular template; its value is what navigation(id) returns, where id is the id attribute (a navigation with only a name attribute gets a hash of the name). A <script type="text/breadcrumb"> gets opt.breadcrumb. Elements with the class CMS_trash or CMS_editor are removed. The CSS and JS of the widgets are minified and joined into page.css and page.js.

Made in Europe