This proc simply gets the file from local disk and then passes it onto render. If partialsDir is not passed a value, then the directory for partials is derived from template_file_path.
Border cases:
Using a when statement, if the library is compiled for javascript, calling renderFile will purposely raise a descriptive error since this can't work under javascript. However, I will ensure that the library itself will compile just fine under javascript.
If the file is not found, rather than raise a runtime error, the procedure would ... I'm not sure. Perhaps return a nil? Or perhaps add an optional fallback_template string parameter that defaults to nil?
This is second of two features I'd be interested in adding to this library.
Currently, the syntax of
render
isrender(tmplate: string, c: Context, partialsDir="."): string
I'm proposing adding another procedure, called
renderFile
, that specifically pulls from a file rather than string:renderFile(template_file_path: string, c: Context, partialsDir=nil): string
This proc simply gets the file from local disk and then passes it onto
render
. IfpartialsDir
is not passed a value, then the directory for partials is derived fromtemplate_file_path
.Border cases:
Using a when statement, if the library is compiled for javascript, calling renderFile will purposely raise a descriptive error since this can't work under javascript. However, I will ensure that the library itself will compile just fine under javascript.
If the file is not found, rather than raise a runtime error, the procedure would ... I'm not sure. Perhaps return a nil? Or perhaps add an optional
fallback_template
string parameter that defaults to nil?