-
Notifications
You must be signed in to change notification settings - Fork 0
0.2.0 Templates
Ivan S Glazunov edited this page Feb 20, 2015
·
9 revisions
import Templates = require('osws-templates');
(argument: any) => boolean;
Templates.isSync(function() {}); // true;
Templates.isSync(function(callback) {}); // false;
Templates.isSync(function(callback, other) {}); // false;
Templates.isSync(function(any, args) {}); // false;
(argument: any) => boolean;
Templates.isAsync(function() {}); // false;
Templates.isAsync(function(callback) {}); // true;
Templates.isAsync(function(callback, other) {}); // false;
Templates.isAsync(function(any, args) {}); // false;
The method of synchronous/asynchronous conversion TData in string values. Is used when rendering.
(instance: Prototype, method: Function) => Function;
Adds a method options __templatesInstance
as reference to an instance of the Prototype.
(data: string, reg: RegExp) => string[][];
RegExp
(_attributes: IAttributes, selector: TSelector) => void;
Parse selector
to IAttributes format.
All sended attributes overlap, not added.
Exception - classes as .class-name-1.class-name-2
, are added, do not overlap.
(string: string, context: Object, callback: TCallback) => void;
By default - wrap around method _.template.
var context: IContext = {
type: 'name',
data: function(callback) { callback('Example'); },
person: {
whose: function() { return 'my'; }
}
};
Templates._stringTemplate('<%= person.whose %> <%= type %>: <%= name %>', context, console.log);
// my name: Example
Templates._stringTemplate = function(string: string, context: Object, callback: (result: any) => any) {
callback(string);
}
- 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