chore(docs)
This commit is contained in:
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user