elseware-nodejs 1.7.3 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5319,16 +5319,20 @@ var TemplateEngine = class {
5319
5319
  static partialsLoaded = {};
5320
5320
  static cssCache = {};
5321
5321
  static registerPartials(templateDir) {
5322
- const partialsDir = path.join(templateDir, "partials");
5323
- if (!fs3.existsSync(partialsDir) || this.partialsLoaded[templateDir]) return;
5324
- const files = fs3.readdirSync(partialsDir);
5325
- for (const file of files) {
5326
- if (file.endsWith(".hbs")) {
5327
- const name = path.basename(file, ".hbs");
5328
- const content = fs3.readFileSync(path.join(partialsDir, file), "utf-8");
5329
- Handlebars.registerPartial(name, content);
5322
+ if (this.partialsLoaded[templateDir]) return;
5323
+ const registerFromDir = (dirPath) => {
5324
+ if (!fs3.existsSync(dirPath)) return;
5325
+ const files = fs3.readdirSync(dirPath);
5326
+ for (const file of files) {
5327
+ if (file.endsWith(".hbs")) {
5328
+ const name = path.basename(file, ".hbs");
5329
+ const content = fs3.readFileSync(path.join(dirPath, file), "utf-8");
5330
+ Handlebars.registerPartial(name, content);
5331
+ }
5330
5332
  }
5331
- }
5333
+ };
5334
+ registerFromDir(path.join(templateDir, "partials"));
5335
+ registerFromDir(path.join(templateDir, "layouts"));
5332
5336
  this.partialsLoaded[templateDir] = true;
5333
5337
  }
5334
5338
  static loadAllCSS(stylesDir) {