From 9770ffe4f341eb8b80cb8e210695e5625cfc8cf3 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Sun, 5 Sep 2010 17:36:14 -0400 Subject: [PATCH] Added compiler. --- lib/handlebars.js | 6 +++++- test/compat.hbs | 8 -------- test/perf.html | 1 + 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 test/compat.hbs diff --git a/lib/handlebars.js b/lib/handlebars.js index eb64b6c3..59de3a0e 100644 --- a/lib/handlebars.js +++ b/lib/handlebars.js @@ -65,7 +65,11 @@ Handlebars = { var compiled = Handlebars.compiledPartials[partial]; if (compiled == null) { - compiled = Handlebars.compile(partial); + if (Handlebars.isFunction(partial)) { + compiled = partial; + } else { + compiled = Handlebars.compile(partial); + } Handlebars.compiledPartials[partial] = compiled; } diff --git a/test/compat.hbs b/test/compat.hbs deleted file mode 100644 index 5dd9cfc1..00000000 --- a/test/compat.hbs +++ /dev/null @@ -1,8 +0,0 @@ -This is the story of guys who work on a project -called {{project}}. Their names were {{#people}}{{firstName}} and {{/people}} -they both enjoyed working on {{project}}. - -{{#people}} -{{>personPet}} -{{/people}} - diff --git a/test/perf.html b/test/perf.html index 8c0ece48..1ec728f1 100644 --- a/test/perf.html +++ b/test/perf.html @@ -14,6 +14,7 @@
    +