...
On the local disk a Squirro widget is a folder. That folder contains a number of files that all have their purpose.
File | Type | Explanation |
---|---|---|
widget.js | JavaScript | The executable code of the widget. This file is loaded when the widget is used on a dashboard. |
widget.css | CSS | Styling of the widget. This file must exist even when no styles are used for the widget. |
widget.html | HTML | Template for the HTML code of the widget. Even if no custom template is used, this file must exist. |
widget.ini widget.ini.orig | Config | Automatically created file - do not create yourself. These files keep track of the widget metadata. |
Managing Widgets (squirro_widget
)
...
The template for a new widget.js
file is as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
return Widgets.Text.extend({ // Class properties and methods here }); |
...
This example highlights the three main template features.
Syntax | Explanation | ||
---|---|---|---|
<%- variable %> | Insert the variable contents with escaping. This escapes any HTML code using the Underline.js escape function. | ||
<%- variable %> | Insert the variable contents in raw form. Any HTML code is passed through verbatim.
| ||
<% JavaScript Code %> | Execute JavaScript code in the current template context. The most common use case for this is a loop as shown in the example above. |