Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

On the local disk a Squirro widget is a folder. That folder contains a number of files that all have their purpose.

FileTypeExplanation
widget.jsJavaScriptThe executable code of the widget. This file is loaded when the widget is used on a dashboard.
widget.cssCSSStyling of the widget. This file must exist even when no styles are used for the widget.
widget.htmlHTMLTemplate 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
languagejs
titlewidget.js
return Widgets.Text.extend({
    // Class properties and methods here
});

...

This example highlights the three main template features.

SyntaxExplanation
<%- 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.

Note

Only use this for data that's from safe locations. Your default method should be to use <%- variable %> for best security.

<% 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.