"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Helper is used to defined shared snippet.
*/
class Helper {
/**
* Register a helper with its name.
* @static
* @param {string} name - the unique helper name.
* @param {Helper} helper - the helper to register.
*/
static register(name, helper) {
this.helpers[name] = helper;
}
/**
* Fetch a helper by name.
* @static
* @param {string} name helper name.
* @returns {Helper} the matching helper.
*/
static fetch(name) {
if (this.helpers[name]) {
return this.helpers[name];
}
}
/**
* Clear all registered helpers.
*/
static clear() {
this.helpers = {};
}
/**
* Create a Helper
* @param {string} name - helper name
* @param {Function} func - a function defines the behaviors of the helper
*/
constructor(name, func) {
this.name = name;
this.func = func;
Helper.register(name, this);
}
}
/**
* Store all helpers grouped by name.
* @static
*/
Helper.helpers = {};
exports.default = Helper;