27 lines
2.7 KiB
JavaScript
27 lines
2.7 KiB
JavaScript
|
"use strict";
|
||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||
|
if (mod && mod.__esModule) return mod;
|
||
|
var result = {};
|
||
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||
|
result["default"] = mod;
|
||
|
return result;
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const plugins = __importStar(require("./smarthbs.plugins"));
|
||
|
/**
|
||
|
* compiles a directory and outputs it
|
||
|
*/
|
||
|
exports.compileDirectory = async (originDirPathArg, destinationDirPathArg, dataFileNameArg) => {
|
||
|
let hbsFilePathArray = plugins.smartfile.fs.listFilesSync(originDirPathArg, /.hbs/);
|
||
|
let data = plugins.smartfile.fs.toObjectSync(plugins.path.join(originDirPathArg, dataFileNameArg));
|
||
|
for (let hbsFilePath of hbsFilePathArray) {
|
||
|
let parsedPath = plugins.path.parse(hbsFilePath);
|
||
|
let hbsFileString = plugins.smartfile.fs.toStringSync(plugins.path.join(originDirPathArg, hbsFilePath));
|
||
|
let template = plugins.handlebars.compile(hbsFileString);
|
||
|
let output = template(data);
|
||
|
console.log('hi ' + output + ' hi');
|
||
|
await plugins.smartfile.fs.ensureDir(destinationDirPathArg);
|
||
|
plugins.smartfile.memory.toFsSync(output, plugins.path.join(destinationDirPathArg, parsedPath.name + '.html'));
|
||
|
}
|
||
|
};
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRoYnMuY29tcGlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0aGJzLmNvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsNERBQThDO0FBRTlDOztHQUVHO0FBQ1EsUUFBQSxnQkFBZ0IsR0FBRyxLQUFLLEVBQ2pDLGdCQUF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