Fix a number of outstanding issues:
* {{}} escape their contents, {{{}}} and {{& }} do not
* Add support in the parser, tokenizer and AST for partials
with context (support is still not there in the runtime)
* Fix some inconsistencies with the old behavior involving
the correct printing of null and undefined
* Add Handlebars.Exception
* Fixed an issue involving ./foo and this/foo
* Fleshed out helperMissing in the specs (this will be
moved out into handlebars proper once registerHelper
and registerPartial are added)
This commit is contained in:
@@ -70,7 +70,7 @@ Handlebars.Runtime = function(context, fallback, stack) {
|
||||
|
||||
var newContext = this.context = new Handlebars.Context;
|
||||
|
||||
if(context.isContext) {
|
||||
if(context && context.isContext) {
|
||||
newContext.data = context.data;
|
||||
newContext.fallback = context.fallback;
|
||||
} else {
|
||||
@@ -103,17 +103,22 @@ Handlebars.Runtime.prototype = {
|
||||
mustache: function(mustache) {
|
||||
var idObj = this.accept(mustache.id);
|
||||
var params = mustache.params;
|
||||
var buf;
|
||||
|
||||
for(var i=0, l=params.length; i<l; i++) {
|
||||
params[i] = this.accept(params[i]).data;
|
||||
}
|
||||
|
||||
if(toString.call(idObj.data) === "[object Function]") {
|
||||
this.buffer = this.buffer + idObj.data.apply(this.wrapContext(), params);
|
||||
buf = idObj.data.apply(this.wrapContext(), params);
|
||||
} else {
|
||||
if(params.length) { throw new Error(mustache.id.parts.join("/") + " is not a Function, so you cannot have Function parameters"); }
|
||||
this.buffer = this.buffer + idObj.data;
|
||||
buf = idObj.data;
|
||||
}
|
||||
|
||||
if(buf && mustache.escaped) { buf = Handlebars.Utils.escapeExpression(buf); }
|
||||
|
||||
this.buffer = this.buffer + (buf == null ? '' : buf);
|
||||
},
|
||||
|
||||
block: function(block) {
|
||||
|
||||
Reference in New Issue
Block a user