chore(docs)

This commit is contained in:
Benjamin Wegener
2024-02-03 01:06:21 +00:00
parent e15ad58fe7
commit 925c4e7df6

View File

@@ -4,6 +4,14 @@ export default class HtmlEngine {
#internalCache = new Map(); #internalCache = new Map();
constructor() {} constructor() {}
/**
* Handles the specified file by loading its content, parsing sections and variables,
* and caching the result.
*
* @param {string} filepath - The path of the file to handle.
* @returns {Object} - An object with a `parse` method that can be used to parse the file.
* @throws {Error} - If the file is not found.
*/
async handle(filepath) { async handle(filepath) {
// load file // load file
const file = Bun.file(filepath); const file = Bun.file(filepath);
@@ -26,6 +34,14 @@ export default class HtmlEngine {
}; };
} }
/**
* Parses the specified identifier using the provided data and options.
* @param {string} identifier - The identifier of the file to parse.
* @param {Object} [data={}] - The data object to replace placeholders in the file content.
* @param {Object} [options={}] - The options object.
* @returns {Response} - The parsed response object.
* @throws {Error} - If the file is not found.
*/
parse(identifier, data = {}, options = {}) { parse(identifier, data = {}, options = {}) {
if (!this.#internalCache.has(identifier)) { if (!this.#internalCache.has(identifier)) {
throw new Error('file not found'); throw new Error('file not found');