Permalink
Browse files

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);
  • Loading branch information...
1 parent 987e000 commit 4c5cf3c4b0092d009401d0a4aea950f6f61bb646 @seanski seanski committed Feb 15, 2013
Showing with 6 additions and 1 deletion.
  1. +4 −1 mustache/mustache-tests.ts
  2. +2 −0 mustache/mustache.d.ts
View
5 mustache/mustache-tests.ts
@@ -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);
View
2 mustache/mustache.d.ts
@@ -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;

0 comments on commit 4c5cf3c

Please sign in to comment.