mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-29 11:12:23 +08:00
Mustache.js definitions and tests added
This commit is contained in:
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
// Type definitions for Mustache 0.7
|
||||
// Project: https://github.com/janl/mustache.js
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface MustacheScanner {
|
||||
string: string;
|
||||
tail: string;
|
||||
pos: number;
|
||||
|
||||
eos(): bool;
|
||||
scan(re: RegExp): string;
|
||||
scanUntil(re: RegExp): string;
|
||||
}
|
||||
|
||||
interface MustacheContext {
|
||||
view;
|
||||
parent;
|
||||
|
||||
clearCache();
|
||||
push(view): MustacheContext;
|
||||
lookup(name: string): any;
|
||||
}
|
||||
|
||||
interface MustacheWriter {
|
||||
clearCache();
|
||||
compile(template: string, tags);
|
||||
compilePartial(name, template, tags);
|
||||
compileTokens(tokens, template);
|
||||
render(template, view, partials);
|
||||
}
|
||||
|
||||
interface MustacheStatic {
|
||||
name: string;
|
||||
version: string;
|
||||
tags: string;
|
||||
Scanner: MustacheScanner;
|
||||
Context: MustacheContext;
|
||||
Writer: MustacheWriter;
|
||||
escape;
|
||||
|
||||
parse(template: string, tags);
|
||||
clearCache(): MustacheWriter;
|
||||
compile(template: string, tags): MustacheWriter;
|
||||
compilePartial(name: string, template: string, tags): MustacheWriter;
|
||||
compileTokens(tokens, template: string): MustacheWriter;
|
||||
render(template: string, view: any, partials?: any): MustacheWriter;
|
||||
to_html(template: string, view: any, partials?: any, send?): string;
|
||||
}
|
||||
|
||||
declare var Mustache: MustacheStatic;
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="../Definitions/mustache.d.ts" />
|
||||
|
||||
var view = { title: "Joe", calc: function () { return 2 + 4; } };
|
||||
var output = Mustache.render("{{title}} spends {{calc}}", view);
|
||||
|
||||
var person;
|
||||
var template = "<h1>{{firstName}} {{lastName}}</h1>Blog: {{blogURL}}";
|
||||
var html = Mustache.to_html(template, person);
|
||||
Reference in New Issue
Block a user