23 lines
2.2 KiB
JavaScript
23 lines
2.2 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const plugins = require("./smarthbs.plugins");
|
||
|
/**
|
||
|
* registers a directory of partials to make them available within handlebars compilation
|
||
|
*/
|
||
|
exports.registerPartialDir = (dirPathArg) => {
|
||
|
let done = plugins.smartq.defer();
|
||
|
plugins.smartfile.fs.listFileTree(dirPathArg, '**/*.hbs').then(hbsFileArrayArg => {
|
||
|
for (let hbsFilePath of hbsFileArrayArg) {
|
||
|
let parsedPath = plugins.path.parse(hbsFilePath);
|
||
|
let hbsFileString = plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, hbsFilePath));
|
||
|
if (parsedPath.dir === '') {
|
||
|
parsedPath.name = '/' + parsedPath.name;
|
||
|
}
|
||
|
let partialName = `partials${parsedPath.dir}${parsedPath.name}`;
|
||
|
plugins.handlebars.registerPartial(partialName, hbsFileString);
|
||
|
done.resolve();
|
||
|
}
|
||
|
});
|
||
|
return done.promise;
|
||
|
};
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRoYnMucGFydGlhbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGhicy5wYXJ0aWFscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDhDQUE2QztBQUU3Qzs7R0FFRztBQUNRLFFBQUEsa0JBQWtCLEdBQUcsQ0FBQyxVQUFrQjtJQUNqRCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQ2pDLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQyxVQUFVLEVBQUUsVUFBVSxDQUFDLENBQUMsSUFBSSxDQUFDLGVBQWU7UUFDNUUsR0FBRyxDQUFDLENBQUMsSUFBSSxXQUFXLElB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