Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Render should use cache when it is available.

  • Loading branch information...
commit eab8ae3714fc4b107e14c64c5d8153f37a3ce4fc 1 parent cda57d6
RayMorgan authored
Showing with 16 additions and 6 deletions.
  1. +16 −6 lib/mu.js
22 lib/mu.js
View
@@ -73,17 +73,27 @@ Mu.compile = function Mu_compile(filename) {
Mu.render = function Mu_render(filename, context) {
var promise = new process.Promise();
- Mu.compile(filename)
- .addCallback(function (compiled) {
+ if (Mu.cache[filename]) {
+ process.nextTick(function () {
try {
- promise.emit('success', compiled(context));
+ promise.emit('success', Mu.cache[filename](context));
} catch (e) {
promise.emit('error', e);
}
- })
- .addErrback(function (e) {
- promise.emit('error', e);
});
+ } else {
+ Mu.compile(filename)
+ .addCallback(function (compiled) {
+ try {
+ promise.emit('success', compiled(context));
+ } catch (e) {
+ promise.emit('error', e);
+ }
+ })
+ .addErrback(function (e) {
+ promise.emit('error', e);
+ });
+ }
return promise;
}
Please sign in to comment.
Something went wrong with that request. Please try again.