In the time of writing, when one imports temple .template, the returned environment consists of two functions: render and render-dict, which is in line with the language accent on printing to stdout. But when you do not use this approach in rendering (as the httpf module of this very library), you have to litter your code with capout calls. I used macro, which will import the library, render it, and capture the stdout, but it does not play well with flycheck lint and janet-lsp server.
I propose to have two more functions returned in the environment, analogous to the two existing ones, but returning the captured string:
capture analog to render
capture-dict analog to render-dict
I am aware of the compile function, but I really like the process of importing templates and then calling the functions.
Also, I will volunteer for the PR if the change is deemed useful.
In the time of writing, when one imports temple
.template
, the returned environment consists of two functions:render
andrender-dict
, which is in line with the language accent on printing to stdout. But when you do not use this approach in rendering (as thehttpf
module of this very library), you have to litter your code withcapout
calls. I used macro, which will import the library, render it, and capture the stdout, but it does not play well with flycheck lint and janet-lsp server.I propose to have two more functions returned in the environment, analogous to the two existing ones, but returning the captured string:
capture
analog torender
capture-dict
analog torender-dict
I am aware of the
compile
function, but I really like the process of importing templates and then calling the functions.Also, I will volunteer for the PR if the change is deemed useful.