Fork me on GitHub

Ractive.js decorator helper plugin

Download: ...more plugins at docs.ractivejs.org/latest/plugins

Ractive.js decorator helper plugin.

Currently two helper methods:

The helper functions are exposed as Ractive.decorators.create and Ractive.decorators.combine. Please note that they are meant to be invoked to create a decorator, and thus will not work as decorators themeselves. Also note that Ractive.decorators.create is not required in order to use Ractive.decorators.combine, through the examples below make use of it.

.create( fn )

Wraps the supplied function as a decorator, called both at load and update. No-op teardown functionality.

this in the function refers to the decorated node.


		


		

.combine( [ { n1: d1 }, { n2: d2 }, ... ])

Wraps the supplied name/decorator pairs as a single decorator. The supplied array order is preserved in load and update.

The decorator is used in the template as:

decorator="alias: { name1: [arg1, arg2, argn], name2: [arg1, arg2, argn]}"

For single argument decortors, the array is optional:

decorator="alias: { name1: arg1, name2: [arg1, arg2]}"

You do not need to include all combined decorators:

decorator="alias: { name1: arg1 }"