Skip to content

0.2.1 theory content

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

theory about content

Element content creation, without tag wrapper. Full documentation.

Double tags operate on the principle of content.

Getting from Templates.content:
var content = Templates.content;
Example:
content('content')
.render(console.log);
content
Content in Templates describes the type TData.
div()(
	123, // number
	'string', // string
	div, // tag constructor
	div('.container'), // tag not complete instance
	div('.container')('data'), // tag instance
	asSync(function() { return 'sync'; }), // sync method
	asAsync(function(callback) { callback('sync'); }), // async method
	[ div ]
).render(console.log)
<div>123string<div></div><div class="container"></div><div class="container">data</div>syncsync<div></div></div>

In short, all the data will be taken literally, except:

As constructor:
content(
	div, br, doctype.html
).render(console.log)
<div></div><br><!DOCTYPE html>
As isntance:
content(
	div('.container')('content', span()('text')), br(), doctype.html()
).render(console.log)
<div class="container">content<span>text</span></div><br><!DOCTYPE html>
As not complete instance:

Div without content.

content(
	div('.container')
).render(console.log)
<div class="container"></div><br><!DOCTYPE html>

The module allows you to work with both synchronous and asynchronous data.

div()(
	asSync(function() { return 'sync' }),
	asAsync(function(callback) { setTimeout(function() { callback('async'); }, 1000); })
).render(console.log)
<div>syncasync</div>
Clone this wiki locally