@@ -3,8 +3,8 @@ import * as Rendering from '@rendering/index.ts'
33import * as EngineParts from '@rendering/engine/index.ts'
44
55/**
6- * Template rendering engine
7- * @description Compiles and renders DVE templates with cache
6+ * Template rendering engine.
7+ * @description Compiles and renders DVE templates with cache.
88 */
99export class Engine implements Types . ViewEngine {
1010 /** Default views directory */
@@ -17,8 +17,8 @@ export class Engine implements Types.ViewEngine {
1717 private discoveredPaths : Set < string > | null = null
1818
1919 /**
20- * Create new engine instance
21- * @description Stores default viewsDir from options
20+ * Create new engine instance.
21+ * @description Stores default viewsDir from options.
2222 * @param options - Engine configuration options
2323 */
2424 constructor ( options : Types . EngineOptions ) {
@@ -40,18 +40,17 @@ export class Engine implements Types.ViewEngine {
4040 this . compileCache . delete ( absPath )
4141 }
4242
43- /** Reset discovered template paths */
44- refreshPaths ( ) : void {
43+ /** Reset discovered template paths */ refreshPaths ( ) : void {
4544 this . discoveredPaths = null
4645 }
4746
4847 /**
49- * Render template with data
50- * @description Loads template and produces final HTML
48+ * Render template with data.
49+ * @description Loads template and produces final HTML.
5150 * @param templatePath - Relative template path
5251 * @param data - Template scope data
5352 * @returns Rendered HTML string
54- * @throws {Error } When template path not discovered
53+ * @throws {Deno.errors.NotFound } When template path not discovered
5554 */
5655 async render ( templatePath : string , data : Types . TemplateData = { } ) : Promise < string > {
5756 const compiled = await this . resolveTemplate ( templatePath )
@@ -64,7 +63,7 @@ export class Engine implements Types.ViewEngine {
6463 * @param templatePath - Relative template path
6564 * @param data - Template scope data
6665 * @returns ReadableStream with HTML content
67- * @throws {Error } When template not found
66+ * @throws {Deno.errors.NotFound } When template not found
6867 */
6968 streamRender ( templatePath : string , data : Types . TemplateData = { } ) : ReadableStream {
7069 const { readable, writable } = new TransformStream ( )
@@ -75,8 +74,8 @@ export class Engine implements Types.ViewEngine {
7574 }
7675
7776 /**
78- * Compile template and cache
79- * @description Parses template text into AST nodes
77+ * Compile template and cache.
78+ * @description Parses template text into AST nodes.
8079 * @param absTemplatePath - Absolute path to template
8180 * @returns Compile result with AST
8281 */
@@ -93,8 +92,8 @@ export class Engine implements Types.ViewEngine {
9392 }
9493
9594 /**
96- * Load template text with cache
97- * @description Loads file contents from disk once
95+ * Load template text with cache.
96+ * @description Loads file contents from disk once.
9897 * @param absPath - Absolute template file path
9998 * @returns Template file contents
10099 */
@@ -109,8 +108,8 @@ export class Engine implements Types.ViewEngine {
109108 }
110109
111110 /**
112- * Render node to chunk
113- * @description Renders individual node to HTML chunk
111+ * Render node to chunk.
112+ * @description Renders individual node to HTML chunk.
114113 * @param node - AST node to render
115114 * @param data - Template scope data
116115 * @param viewsDir - Root directory for includes
@@ -164,8 +163,8 @@ export class Engine implements Types.ViewEngine {
164163 }
165164
166165 /**
167- * Render AST nodes to HTML
168- * @description Evaluates variables, includes, and blocks
166+ * Render AST nodes to HTML.
167+ * @description Evaluates variables, includes, and blocks.
169168 * @param ast - Parsed template AST nodes
170169 * @param data - Current scope data
171170 * @param viewsDir - Root directory for includes
@@ -187,8 +186,8 @@ export class Engine implements Types.ViewEngine {
187186 }
188187
189188 /**
190- * Render template nodes to stream
191- * @description Streams HTML output progressively
189+ * Render template nodes to stream.
190+ * @description Streams HTML output progressively.
192191 * @param templatePath - Relative template path
193192 * @param data - Template scope data
194193 * @param writable - Writable stream for output
@@ -218,7 +217,7 @@ export class Engine implements Types.ViewEngine {
218217 * @description Discovers paths, normalizes, validates, and compiles.
219218 * @param templatePath - Relative template path
220219 * @returns Compiled template with AST
221- * @throws {Error } When template not found
220+ * @throws {Deno.errors.NotFound } When template not found
222221 */
223222 private async resolveTemplate ( templatePath : string ) : Promise < Types . CompileResult > {
224223 if ( this . discoveredPaths === null ) {
@@ -229,7 +228,7 @@ export class Engine implements Types.ViewEngine {
229228 ? normalizedPath
230229 : `${ normalizedPath } .dve`
231230 if ( ! this . discoveredPaths . has ( pathWithExt ) ) {
232- throw new Error ( `Template "${ templatePath } " not found in views directory` )
231+ throw new Deno . errors . NotFound ( `Template "${ templatePath } " not found in views directory` )
233232 }
234233 const absPath = EngineParts . Utils . join ( this . defaultViewsDir , pathWithExt )
235234 return await this . compileTemplate ( absPath )
0 commit comments