Minor tweaks

This commit is contained in:
David Greenspan
2014-05-06 17:47:13 -07:00
parent 60a4b0ac19
commit bee046de64
2 changed files with 21 additions and 5 deletions

View File

@@ -156,4 +156,4 @@ outerRange.attach(document.body);
// outerRange.stop();
// ```
});
});

View File

@@ -5,10 +5,10 @@
// computation).
Blaze._inDummyComputation = function (f) {
var ret;
Deps.autorun(function (c) {
Blaze._wrapAutorun(Deps.autorun(function (c) {
c.stop();
ret = f();
});
}));
return ret;
};
@@ -26,6 +26,11 @@ Blaze.ToTextVisitor = HTML.ToTextVisitor.extend({
}
});
var ToTextController = Blaze.ToTextController = function () {
Blaze.Controller.call(this);
};
__extends(Blaze.ToTextController, Blaze.Controller);
Blaze.toText = function (content, textMode) {
if (! Deps.active) {
return Blaze._inDummyComputation(function () {
@@ -43,7 +48,10 @@ Blaze.toText = function (content, textMode) {
var visitor = new Blaze.ToTextVisitor;
visitor.textMode = textMode;
return visitor.visit(content);
var controller = (Blaze.currentController || new ToTextController);
return Blaze.withCurrentController(controller, function () {
return visitor.visit(content);
});
};
////////////////////////////// Blaze.toHTML
@@ -60,6 +68,11 @@ Blaze.ToHTMLVisitor = HTML.ToHTMLVisitor.extend({
}
});
var ToHTMLController = Blaze.ToHTMLController = function () {
Blaze.Controller.call(this);
};
__extends(Blaze.ToHTMLController, Blaze.Controller);
// This function is mainly for server-side rendering and is not in the normal
// code path for client-side rendering.
Blaze.toHTML = function (content) {
@@ -68,7 +81,10 @@ Blaze.toHTML = function (content) {
return Blaze.toHTML(content);
});
}
return (new Blaze.ToHTMLVisitor).visit(content);
var controller = (Blaze.currentController || new ToHTMLController);
return Blaze.withCurrentController(controller, function () {
return (new Blaze.ToHTMLVisitor).visit(content);
});
};