@sprucelabs/spruce-templates
Version:
Templates used for code generation in skills!
24 lines (23 loc) • 1.14 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const handlebars_1 = __importDefault(require("handlebars"));
handlebars_1.default.registerHelper('schemaNamespacePath', function (options) {
var _a, _b;
const { schemaTemplateItem } = options.hash;
if (!schemaTemplateItem) {
throw new Error(`schemaNamespacePath needs schemaTemplateItem=item`);
}
const { globalSchemaNamespace } = (_b = (_a = options === null || options === void 0 ? void 0 : options.data) === null || _a === void 0 ? void 0 : _a.root) !== null && _b !== void 0 ? _b : {};
if (!globalSchemaNamespace) {
throw new Error('schemaNamespacePath template addon needs globalSchemaNamespace in the root context.');
}
let path = `${globalSchemaNamespace}.${schemaTemplateItem.namespace}`;
if (schemaTemplateItem.schema.version) {
path += `.${schemaTemplateItem.schema.version}`;
}
path += `.${schemaTemplateItem.namePascal}`;
return path;
});