Templates
Template - an HTML structure with added variables, expressions, and directives. When working with templates, the template engine lodash.template is used, which accesses the settings object assigned when creating a widget.
In order to use a template, you must pass it in the tpl property:
var sitephone = CallGear.UI.createWidget('sitephone', {
settings: settings,
tpl: '<div>my template</div>'
});
This template is transformed into a DOM element after calling render, and is accessible through a call to the getEl method.
sitephone.render();
var el = sitephone.getEl();
This is not the only way to bind a DOM element to a widget. Also, when creating a widget, you can pass an already prepared element:
var sitephone = CallGear.UI.createWidget('sitephone', {
tpl: document.getElementById('sitephone_el')
});
In this case, do not use the render method; settings are not taken into account, since the finished element is taken from the page as-is.