Allow MustacheWriter to be called as a function with the view as the parameter.

For example, the documentation for Mustache.js shows the following:
var compiledTemplate = Mustache.compile(stringTemplate);
var templateOutput = compiledTemplate(templateData);
This commit is contained in:
Sean Hill
2013-02-15 13:30:45 -06:00
parent 987e000332
commit 4c5cf3c4b0
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -5,4 +5,7 @@ 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);
var html = Mustache.to_html(template, person);
var writer = Mustache.compile(template);
var writerOutput = writer(view);
+2
View File
@@ -24,6 +24,7 @@ interface MustacheContext {
}
interface MustacheWriter {
(view: any): string;
clearCache();
compile(template: string, tags);
compilePartial(name, template, tags);
@@ -42,6 +43,7 @@ interface MustacheStatic {
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;