From 4c5cf3c4b0092d009401d0a4aea950f6f61bb646 Mon Sep 17 00:00:00 2001 From: Sean Hill Date: Fri, 15 Feb 2013 13:30:45 -0600 Subject: [PATCH] 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); --- mustache/mustache-tests.ts | 5 ++++- mustache/mustache.d.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mustache/mustache-tests.ts b/mustache/mustache-tests.ts index 744e85585..9b42131ef 100644 --- a/mustache/mustache-tests.ts +++ b/mustache/mustache-tests.ts @@ -5,4 +5,7 @@ var output = Mustache.render("{{title}} spends {{calc}}", view); var person; var template = "

{{firstName}} {{lastName}}

Blog: {{blogURL}}"; -var html = Mustache.to_html(template, person); \ No newline at end of file +var html = Mustache.to_html(template, person); + +var writer = Mustache.compile(template); +var writerOutput = writer(view); diff --git a/mustache/mustache.d.ts b/mustache/mustache.d.ts index 1bc1a6cdd..c1be75afd 100644 --- a/mustache/mustache.d.ts +++ b/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;