UNPKG

@miyagi/core

Version:

miyagi is a component development tool for JavaScript template engines.

24 lines (19 loc) 542 B
/** * Module for getting all partials * @module statePartials */ import * as helpers from "../helpers.js"; export const getPartials = function (tree) { const partials = {}; (function getPartials(entry) { if ( entry.type === "file" && entry.name.endsWith(`.${global.config.files.templates.extension}`) ) { partials[helpers.getShortPathFromFullPath(entry.path)] = entry.path; } else if (entry.type === "directory") { entry.children.forEach((item) => getPartials(item)); } })(tree.components); return partials; };