From c48221656509d5fc9de3e813b8020d738be3c504 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sat, 5 Sep 2020 10:46:22 -0500 Subject: [PATCH] remove file:// on view engine template render --- TODO.txt | 2 +- lib/src/unit/ViewEngine.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index bac61c4..6a5b1db 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,6 @@ TLS support internationalization -uploads & universal path +uploads & universal path!! CLI - view routes, template generation, start server, directives, output, args nicer error and home pages favicon diff --git a/lib/src/unit/ViewEngine.ts b/lib/src/unit/ViewEngine.ts index a38ba6a..3aaddf2 100644 --- a/lib/src/unit/ViewEngine.ts +++ b/lib/src/unit/ViewEngine.ts @@ -72,7 +72,10 @@ console.log('view engine template dir', { base_dir, template_dir: this.template_ * @return Promise */ public async template(template_path: string, data: { [key: string]: any } = {}) { - const file_path = `${this.template_path(template_path.replace(/:/g, '/'))}${this.get_file_extension()}` + let file_path = `${this.template_path(template_path.replace(/:/g, '/'))}${this.get_file_extension()}` + if ( file_path.startsWith('file://') ) { + file_path = file_path.slice(7) + } this.logger.debug(`Rendering template "${template_path}" from file: ${file_path}`)