Skip to content

0.2.7 usage data

Ivan S Glazunov edited this page Feb 20, 2015 · 2 revisions

Data?

All data passed to the content or attributes are not static. They are rendered at the time of render calls element. Due to this, they may comprise calculated values.

By the static is not calculated automatically include all types of standard JavaScript types.

Calculates types are elements and special functions, synchronous and asynchronous.

Example of synchronous and asynchronous functions:

var asSync = Templates.asSync, asAsync = Templates.asAsync;
div()(asSync(function() { return 'sync'; })).render(console.log); // <div>sync</div>
div()(asAsync(function(callback) { callback('async'); })).render(console.log); // <div>async</div>

The return value is again subjected to rendering. This means that you can return items in any form.

div()(asSync(function() { return div; })).render(console.log); // <div><div></div></div>
div()(asAsync(function(callback) { callback(div); })).render(console.log); // <div><div></div></div>

Clone this wiki locally