Create runtime specific module
This commit is contained in:
+5
-27
@@ -1,11 +1,4 @@
|
||||
module base from "./handlebars/base";
|
||||
|
||||
// Each of these augment the Handlebars object. No need to setup here.
|
||||
// (This is done to easily share code between commonjs and browse envs)
|
||||
import SafeString from "./handlebars/safe-string";
|
||||
import Exception from "./handlebars/exception";
|
||||
module Utils from "./handlebars/utils";
|
||||
module runtime from "./handlebars/runtime";
|
||||
import Handlebars from "./handlebars.runtime";
|
||||
|
||||
// Compiler imports
|
||||
module AST from "./handlebars/compiler/ast";
|
||||
@@ -13,27 +6,12 @@ import { parser as Parser, parse } from "./handlebars/compiler/base";
|
||||
import { Compiler, compile, precompile } from "./handlebars/compiler/compiler";
|
||||
import JavaScriptCompiler from "./handlebars/compiler/javascript-compiler";
|
||||
|
||||
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
|
||||
var _create = Handlebars.create;
|
||||
var create = function() {
|
||||
var hb = {},
|
||||
env = new base.HandlebarsEnvironment();
|
||||
|
||||
// support new environments in global namespace mode
|
||||
hb.registerHelper = env.registerHelper.bind(env);
|
||||
hb.registerPartial = env.registerPartial.bind(env);
|
||||
|
||||
Utils.extend(hb, base);
|
||||
hb.SafeString = SafeString;
|
||||
hb.Exception = Exception;
|
||||
hb.Utils = Utils;
|
||||
|
||||
hb.VM = runtime;
|
||||
hb.template = runtime.template;
|
||||
var hb = _create();
|
||||
|
||||
hb.compile = function(input, options) {
|
||||
options = options || {};
|
||||
options.env = options.env || env;
|
||||
return compile(input, options);
|
||||
return compile(input, options, hb);
|
||||
};
|
||||
hb.precompile = precompile;
|
||||
|
||||
@@ -46,7 +24,7 @@ var create = function() {
|
||||
return hb;
|
||||
};
|
||||
|
||||
var Handlebars = create();
|
||||
Handlebars = create();
|
||||
Handlebars.create = create;
|
||||
|
||||
export default Handlebars;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
module base from "./handlebars/base";
|
||||
|
||||
// Each of these augment the Handlebars object. No need to setup here.
|
||||
// (This is done to easily share code between commonjs and browse envs)
|
||||
import SafeString from "./handlebars/safe-string";
|
||||
import Exception from "./handlebars/exception";
|
||||
module Utils from "./handlebars/utils";
|
||||
module runtime from "./handlebars/runtime";
|
||||
|
||||
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
|
||||
var create = function() {
|
||||
var hb = new base.HandlebarsEnvironment();
|
||||
|
||||
Utils.extend(hb, base);
|
||||
hb.SafeString = SafeString;
|
||||
hb.Exception = Exception;
|
||||
hb.Utils = Utils;
|
||||
|
||||
hb.VM = runtime;
|
||||
hb.template = function(spec) {
|
||||
return runtime.template(spec, hb);
|
||||
};
|
||||
|
||||
return hb;
|
||||
};
|
||||
|
||||
var Handlebars = create();
|
||||
Handlebars.create = create;
|
||||
|
||||
export default Handlebars;
|
||||
Reference in New Issue
Block a user