{{/mylist}}
{{^user}}Not logged in{{/user}}
{{#user}}Welcome, sire{{/user}}
{{>partialName}}
{{#statusDogs[selected]}}
## Transformed attributes
This transforms the `list` attribute via a helper function called `sort()`.
{{# sort(list, "name") :num }}
{{num}} - {{name}}
{{/ end. any text goes here }}
data: {
sort: function(array, column) { return array.whatever(); }
}
## Transitions
Ractive.transitions.bump = function(t, params) {
params = t.processParams( params, {
duration: 400,
color: t.isIntro ? 'rgb(0,255,0)' : 'rgb(255,0,0)'
});
if (t.isIntro) {
/* enter */
} else {
/* exit */
}
t.complete();
};
## [Decorators](http://docs.ractivejs.org/latest/decorators)
Hover me
decorators: {
tooltip: function (node, content) {
// setup code here
return {
teardown: function () {
// cleanup code here
}
}
}
}
Hover me
tooltip: function (node, a, b, two, c) { ... }
## [Adaptors](http://docs.ractivejs.org/latest/adaptors)
myAdaptor = {
filter: function (object, keypath, ractive) {
// return `true` if a particular object is of the type we want to adapt
},
wrap: function (ractive, object, keypath, prefixer) {
// set up event bindings here
object.on('change', function () { ractive.set(prefixer({...})); });
// then return a wrapper:
return {
teardown: function () { .. },
// json representation
get: function () { return { a:2, b:3, c:4, ... }; },
// called on ractive.set
set: function (key, val) { },
// called on ractive.set on root (return false = die)
reset: function (data) { return false; }
};
}
};
## [Computed properties](http://docs.ractivejs.org/latest/computed-properties)
new Ractive({
template: '{{area}}',
computed: {
area: function () { return this.get('width') * this.get('height'); }
area: '${width} * ${height}'
fullname: {
get: '${first} + " " + ${last}"
set: function (name) { ... }
}
}
});
{% endraw %}