spork icon indicating copy to clipboard operation
spork copied to clipboard

Capturing functions for the temple

Open pepe opened this issue 7 months ago • 2 comments

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.

pepe avatar Jun 25 '24 08:06 pepe