Skip to content

0.2.2 t TData

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

TData

type TData = Prototype|TSync|TAsync|any;

Describes the Protocol data storage in unfinished form. When rendering with Templates.dataRender, depending on the type of data are converted into result format.

Applies everywhere in the module.

  • The content in any form is render as TData.
  • The attributes of the tags are rendered as TData.
  • The context is passed when the rendering is render as TData.

Examples

There will be no code producing the rendering. Only TData before rendering, and results after rendering.

Standard type for JavaScript not change their behavior. If you will be given a number, string, function, array, object, or null, they will be transferred to the rendering literally unchanged.

Exceptional behavior:

Elements

Elements sended in any form, will be render.

  • div to <div></div>

  • div('.class') to <div class="class"></div>

  • div('.class')('content') to <div class="class">content</div>

  • img to <img/>

  • img('.class') to <img class="class"/>

  • doctype.html to <!DOCTYPE html>

  • doctype.html('[PUBLIC]') to <!DOCTYPE html PUBLIC>

  • content to

  • content('text') to text

Syns and Async

Possible to send the generated, calculated content.

  • asSync(function() { return 'sync'; }) to sync
  • asAsync(function(callback) { callback('async'); }) to async

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

  • asSync(function() { return div; }) to <div></div>
  • asAsync(function(callback) { callback(div('.class')('content')); }) to <div class="class">content</div>
Clone this wiki locally