mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Precompiler should apply get
magic too
This commit is contained in:
parent
4bbbdd8dc4
commit
7b755c3280
1 changed files with 24 additions and 21 deletions
|
@ -68,27 +68,7 @@
|
||||||
RawHandlebars.JavaScriptCompiler.prototype.compiler = RawHandlebars.JavaScriptCompiler;
|
RawHandlebars.JavaScriptCompiler.prototype.compiler = RawHandlebars.JavaScriptCompiler;
|
||||||
RawHandlebars.JavaScriptCompiler.prototype.namespace = "Discourse.EmberCompatHandlebars";
|
RawHandlebars.JavaScriptCompiler.prototype.namespace = "Discourse.EmberCompatHandlebars";
|
||||||
|
|
||||||
RawHandlebars.precompile = function(value, asObject) {
|
function replaceGet(ast) {
|
||||||
var ast = Handlebars.parse(value);
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
knownHelpers: {
|
|
||||||
get: true
|
|
||||||
},
|
|
||||||
data: true,
|
|
||||||
stringParams: true
|
|
||||||
};
|
|
||||||
|
|
||||||
asObject = asObject === undefined ? true : asObject;
|
|
||||||
|
|
||||||
var environment = new RawHandlebars.Compiler().compile(ast, options);
|
|
||||||
return new RawHandlebars.JavaScriptCompiler().compile(environment, options, undefined, asObject);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
RawHandlebars.compile = function(string) {
|
|
||||||
var ast = Handlebars.parse(string);
|
|
||||||
|
|
||||||
var visitor = new Handlebars.Visitor();
|
var visitor = new Handlebars.Visitor();
|
||||||
visitor.mutating = true;
|
visitor.mutating = true;
|
||||||
|
|
||||||
|
@ -109,6 +89,29 @@
|
||||||
return Handlebars.Visitor.prototype.MustacheStatement.call(this, mustache);
|
return Handlebars.Visitor.prototype.MustacheStatement.call(this, mustache);
|
||||||
};
|
};
|
||||||
visitor.accept(ast);
|
visitor.accept(ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
RawHandlebars.precompile = function(value, asObject) {
|
||||||
|
var ast = Handlebars.parse(value);
|
||||||
|
replaceGet(ast);
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
knownHelpers: {
|
||||||
|
get: true
|
||||||
|
},
|
||||||
|
data: true,
|
||||||
|
stringParams: true
|
||||||
|
};
|
||||||
|
|
||||||
|
asObject = asObject === undefined ? true : asObject;
|
||||||
|
|
||||||
|
var environment = new RawHandlebars.Compiler().compile(ast, options);
|
||||||
|
return new RawHandlebars.JavaScriptCompiler().compile(environment, options, undefined, asObject);
|
||||||
|
};
|
||||||
|
|
||||||
|
RawHandlebars.compile = function(string) {
|
||||||
|
var ast = Handlebars.parse(string);
|
||||||
|
replaceGet(ast);
|
||||||
|
|
||||||
// this forces us to rewrite helpers
|
// this forces us to rewrite helpers
|
||||||
var options = { data: true, stringParams: true };
|
var options = { data: true, stringParams: true };
|
||||||
|
|
Loading…
Reference in a new issue