Update rivets and its test

This commit is contained in:
Stefan Geneshky
2015-11-23 14:39:56 -08:00
parent aed176536a
commit 58641fd48c
2 changed files with 79 additions and 43 deletions
+19 -15
View File
@@ -1,18 +1,22 @@
/// <reference path="rivets.d.ts" />
Rivets.configure({
// Attribute prefix in templates
prefix: 'rv',
// Preload templates with initial data on bind
preloadData: true,
// Root sightglass interface for keypaths
rootInterface: '.',
// Template delimiters for text bindings
templateDelimiters: ['[[', ']]'],
// Augment the event handler of the on-* binder
handler: function(target:any, event:any, binding:any) {
this.call(target, event, binding.view.models)
}
})
rivets.configure({
// Attribute prefix in templates
prefix: 'rv',
// Preload templates with initial data on bind
preloadData: true,
// Root sightglass interface for keypaths
rootInterface: '.',
// Template delimiters for text bindings
templateDelimiters: ['[[', ']]'],
// Augment the event handler of the on-* binder
handler: function(target:any, event:any, binding:any) {
this.call(target, event, binding.view.models)
}
});
var t = {test: ["hello", "one", "two"]}
Rivets.bind(document.getElementById("para1"), t)
var opts = {bar: "foo"};
rivets.bind(document.getElementById("para1"), t);
rivets.bind(document.getElementById("para1"), t, opts);
rivets.bind([document.getElementById("para1"), document.getElementById("para2")], t);
+60 -28
View File
@@ -3,33 +3,65 @@
// Definitions by: Trevor Baron <https://github.com/TrevorDev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface FinchStatic {
configure(options?: {
/**
* Attribute prefix in templates
*/
prefix?: string;
/**
* Preload templates with initial data on bind
*/
preloadData?: boolean;
/**
* Root sightglass interface for keypaths
*/
rootInterface?: string;
/**
* Template delimiters for text bindings
*/
templateDelimiters?: Array<string>
/**
* Augment the event handler of the on-* binder
*/
handler?: Function;
}):void;
bind(element:any, template:any):void;
/// <reference path="../jquery/jquery.d.ts" />
declare module Rivets {
interface View {
build(): void;
bind(): void;
unbind(): void;
}
interface Rivets {
// Global binders.
binders: Object;
// Global components.
components: Object;
// Global formatters.
formatters: Object;
// Global sightglass adapters.
adapters: Object;
// Default attribute prefix.
prefix: string;
// Default template delimiters.
templateDelimiters: Array<string>;
// Default sightglass root interface.
rootInterface: string;
// Preload data by default.
preloadData: boolean;
handler(context: any, ev: Event, biding: any): void;
configure(options?: {
// Attribute prefix in templates
prefix?: string;
//Preload templates with initial data on bind
preloadData?: boolean;
//Root sightglass interface for keypaths
rootInterface?: string;
// Template delimiters for text bindings
templateDelimiters?: Array<string>
// Augment the event handler of the on-* binder
handler?: Function;
}): void;
bind(element: HTMLElement, models: Object, options?: Object): View;
bind(element: JQuery, models: Object, options?: Object): View;
bind(element: Array<HTMLElement>, models: Object, options?: Object): View;
}
}
declare var Rivets: FinchStatic;
declare module "rivets" {
export = Rivets;
}
declare var rivets: Rivets.Rivets;