Make {{#if content}} work.

This lets you check whether a template was invoked via
inclusion or as a block helper. An example is the
api_box template in docs.
This commit is contained in:
Avital Oliver
2014-01-22 15:43:35 -08:00
parent 0a93fa46b9
commit 91cce88c91

View File

@@ -302,6 +302,14 @@ var codeGenMustache = function (tag, mustacheType) {
//
// No code is generated to call the result if it's a function.
var codeGenPath = function (path) {
// Let {{#if content}} check whether this template was invoked via
// inclusion or as a block helper.
if (builtInComponents.hasOwnProperty(path[0])) {
if (path.length > 1)
throw new Error("Unexpected dotted path beginning with " + path[0]);
return builtInComponents[path[0]];
}
var code = 'self.lookup(' + toJSLiteral(path[0]) + ')';
if (path.length > 1) {