Merge pull request #2862 from markashleybell/mustache-0.8.2

Add definitions for mustache.js 0.8.2
This commit is contained in:
Masahiro Wakame
2014-09-25 00:29:18 +09:00
6 changed files with 89 additions and 27 deletions
+11
View File
@@ -0,0 +1,11 @@
/// <reference path="mustache-0.7.3.d.ts" />
var view = { title: "Joe", calc: function () { return 2 + 4; } };
var output = Mustache.render("{{title}} spends {{calc}}", view);
var person = { firstName: "John", lastName: "Smith", blogURL: "http://testblog.com" };
var template = "<h1>{{firstName}} {{lastName}}</h1>Blog: {{blogURL}}";
var html = Mustache.to_html(template, person);
var writer = Mustache.compile(template);
var writerOutput = writer(view);
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for Mustache 0.7.3
// Project: https://github.com/janl/mustache.js
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface MustacheScanner {
string: string;
tail: string;
pos: number;
eos(): boolean;
scan(re: RegExp): string;
scanUntil(re: RegExp): string;
}
interface MustacheContext {
view: any;
parent: MustacheContext;
clearCache(): void;
push(view: any): MustacheContext;
lookup(name: string): any;
}
interface MustacheWriter {
(view: any): string;
clearCache(): void;
compile(template: string, tags: any): any;
compilePartial(name: string, template: string, tags: any): any;
compileTokens(tokens: string[], template: string): any;
render(template: string, view: any, partials: any): any;
}
interface MustacheStatic {
name: string;
version: string;
tags: string;
Scanner: MustacheScanner;
Context: MustacheContext;
Writer: MustacheWriter;
escape: any;
parse(template: string, tags: any): any;
clearCache(): MustacheWriter;
compile(template: string): MustacheWriter;
compile(template: string, tags: any): MustacheWriter;
compilePartial(name: string, template: string, tags: any): MustacheWriter;
compileTokens(tokens: string[], template: string): MustacheWriter;
render(template: string, view: any, partials?: any): string;
to_html(template: string, view: any, partials?: any, send?: any): string;
}
declare var Mustache: MustacheStatic;
+10 -7
View File
@@ -1,11 +1,14 @@
/// <reference path="mustache.d.ts" />
var view = { title: "Joe", calc: function () { return 2 + 4; } };
var output = Mustache.render("{{title}} spends {{calc}}", view);
var view1 = { title: "Joe", calc: function () { return 2 + 4; } };
var template1 = "{{title}} spends {{calc}}";
var output = Mustache.render(template1, view1);
var person;
var template = "<h1>{{firstName}} {{lastName}}</h1>Blog: {{blogURL}}";
var html = Mustache.to_html(template, person);
var view2 = { forename: "Jane", calc: function () { return 10 + 5; } };
var template2 = "{{forename}} spends {{calc}}";
Mustache.parse(template2, null);
var output2 = Mustache.render(template2, view2);
var writer = Mustache.compile(template);
var writerOutput = writer(view);
var view3 = { firstName: "John", lastName: "Smith", blogURL: "http://testblog.com" };
var template3 = "<h1>{{firstName}} {{lastName}}</h1>Blog: {{blogURL}}";
var html = Mustache.to_html(template3, view3);
-1
View File
@@ -1 +0,0 @@
+13 -18
View File
@@ -1,6 +1,6 @@
// Type definitions for Mustache 0.7
// Type definitions for Mustache 0.8.2
// Project: https://github.com/janl/mustache.js
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions by: Mark Ashley Bell <https://github.com/markashleybell/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -15,21 +15,20 @@ interface MustacheScanner {
}
interface MustacheContext {
view;
parent;
view: any;
parentContext: MustacheContext;
clearCache();
push(view): MustacheContext;
push(view: any): MustacheContext;
lookup(name: string): any;
}
interface MustacheWriter {
(view: any): string;
clearCache();
compile(template: string, tags);
compilePartial(name, template, tags);
compileTokens(tokens, template);
render(template, view, partials);
clearCache(): void;
parse(template: string, tags?: any): any;
render(template: string, view: any, partials: any): string;
renderTokens(tokens: string[], context: MustacheContext, partials: any, originalTemplate: any): string;
}
interface MustacheStatic {
@@ -39,16 +38,12 @@ interface MustacheStatic {
Scanner: MustacheScanner;
Context: MustacheContext;
Writer: MustacheWriter;
escape;
escape: any;
parse(template: string, tags);
clearCache(): MustacheWriter;
compile(template: string): MustacheWriter;
compile(template: string, tags): MustacheWriter;
compilePartial(name: string, template: string, tags): MustacheWriter;
compileTokens(tokens, template: string): MustacheWriter;
parse(template: string, tags?: any): any;
render(template: string, view: any, partials?: any): string;
to_html(template: string, view: any, partials?: any, send?): string;
to_html(template: string, view: any, partials?: any, send?: any): any;
}
declare var Mustache: MustacheStatic;
-1
View File
@@ -1 +0,0 @@