The config plugin doesn't expose useful methods. But it serves a useful purpose for spirits that like to be configured from the server side or in a template file.

Config properties

When the spirit initializes, the plugin will collect all DOM attributes prefixed with gui.

<div class="my-spirit" gui.visible="false"></div>

This happens exactly when the onconfigure method is called. The name and value of gui attributes will be mapped directly onto JavaScript properties of the spirit.'.my-spirit', gui.Spirit.extend ({
	visible: true, // must be declared
	onconfigure: function() {
		if(!this.visible) {

The spirit must declare the property in advance, otherwise an error will be thrown, just to make sure that we remember to update the HTML whenever we rename the property.

The attribute value will be converted to an appropriate type, in this case a boolean. In the example below, the attribute values will be converted to a number, an array and an object.

<div class="my-spirit" 
	gui.mincount="{value: 23}">

Actually support arrays and objects.

The gui attribute can also configure nested objects. Here we configure an imaginary randomizer plugin that generates random numbers. You can check out how to create plugins if you like.

<div class="my-spirit" 

Config methods

If the attribute name matches a method, the method will be invoked with with the attribute value as an argument. Again, the value will be converted to a convenient type. In this case, it gets to stay a string.

<div class="my-spirit" gui.logmessage="Hello world"></div>'.my-spirit', gui.Spirit.extend ({
	logmessage: function(message) {

Importantly, a method gets triggered at onready while a property gets set a onconfigure. Please refer to the spirit lifecycle for an overview of these events. You can say that:

You can implement the property with an accessor if you need to run some code when the plugin sets the property (during onconfigure).

Make sure that link leads to something