summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/base.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/base.js')
-rw-r--r--lib/handlebars/base.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js
index 41bb98d..e59f5e7 100644
--- a/lib/handlebars/base.js
+++ b/lib/handlebars/base.js
@@ -1,6 +1,7 @@
import {createFrame, extend, toString} from './utils';
import Exception from './exception';
import {registerDefaultHelpers} from './helpers';
+import {registerDefaultDecorators} from './decorators';
import logger from './logger';
export const VERSION = '3.0.1';
@@ -17,11 +18,13 @@ export const REVISION_CHANGES = {
const objectType = '[object Object]';
-export function HandlebarsEnvironment(helpers, partials) {
+export function HandlebarsEnvironment(helpers, partials, decorators) {
this.helpers = helpers || {};
this.partials = partials || {};
+ this.decorators = decorators || {};
registerDefaultHelpers(this);
+ registerDefaultDecorators(this);
}
HandlebarsEnvironment.prototype = {
@@ -54,6 +57,18 @@ HandlebarsEnvironment.prototype = {
},
unregisterPartial: function(name) {
delete this.partials[name];
+ },
+
+ registerDecorator: function(name, fn) {
+ if (toString.call(name) === objectType) {
+ if (fn) { throw new Exception('Arg not supported with multiple decorators'); }
+ extend(this.decorators, name);
+ } else {
+ this.decorators[name] = fn;
+ }
+ },
+ unregisterDecorator: function(name) {
+ delete this.decorators[name];
}
};