-
Notifications
You must be signed in to change notification settings - Fork 0
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;
content('content')
.render(console.log);
content
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:
content(
div, br, doctype.html
).render(console.log)
<div></div><br><!DOCTYPE html>
content(
div('.container')('content', span()('text')), br(), doctype.html()
).render(console.log)
<div class="container">content<span>text</span></div><br><!DOCTYPE html>
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>
- TData: Renderer|sync|async|Mixin
- TCallback: (error, result) => void
- TSelector: string
- TInjector: () => void
- TAttributes: [name: string]: TData
- TContext: TData
Node.js:
var T = require('oswst');
Require.js:
define(['oswst'], function(T) {});
window
:
var T = window.oswst(_, async);
-
Templates
- .compile
- .include
- .render
- .renderContext
- .renderAttributes
- .renderSelector
- .sync
- .isSyncFunction
- .async
- .isAsyncFunction
- .Prototype()
- .Renderer > .Prototype
- .Data > .Renderer
- .data > .Data
- .Tag > .data
- .Single > .Tag
- .singles[string]
- .Double > .Tag
- .doubles[string]
- .Doctype > .Tag
- .doctypes[string]
- .xml > .Tag
- .Mixin > .Data
- .mixin > .Mixin
- .mixins[string]
- .Module > .Renderer
- .with