From 925c4e7df64729ad465abecc8f4e4e1207f06851 Mon Sep 17 00:00:00 2001 From: Benjamin Wegener Date: Sat, 3 Feb 2024 01:06:21 +0000 Subject: [PATCH] chore(docs) --- src/Views/Html.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Views/Html.js b/src/Views/Html.js index 06e6696..ad20d5f 100644 --- a/src/Views/Html.js +++ b/src/Views/Html.js @@ -4,6 +4,14 @@ export default class HtmlEngine { #internalCache = new Map(); 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) { // load file 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 = {}) { if (!this.#internalCache.has(identifier)) { throw new Error('file not found');