From 621d1765a335a825f8df361aa24f1421b314fb64 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sun, 23 May 2021 16:36:06 +0200 Subject: [PATCH] updated readme in include new interfaces --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a9b6ae..68b10b0 100644 --- a/README.md +++ b/README.md @@ -143,11 +143,22 @@ Include the `templates.h` file into your program. #include ``` -Use the function `renderTemplate()` to render a template with a given namen. The first argument is the name of the template, the second one is the `FILE*` into with the template will be rendered. The following arguments are the parameters of the template itself (in the order that they were declared in the template file). +The function `renderTemplate()` will render the template with the given name to a `FILE*`. The first argument is the name of the template, the second one is the `FILE*` into which the template will be rendered. The following arguments are the parameters of the template itself (in the order that they were declared in the template file). + +The function `sizeTemplate()` will return the exact length of the output of a render. The first argument is the name of the template. The following arguments are the template parameters. + +The function `renderTemplateStr()` will return a string containing the rendered template. The first argument is the name of the template. Followed by the template parameters. Note that the string is allocated on the heap - the result has to be freed manually. Following example shows how this could look like (using the previous discussed "Complete Example" withe name specified in "Translating Template"). ``` -renderTemplate("templates/index.html.templ", qstdout, "Page Title", userArray, userArrayLength); +renderTemplate("templates/index.html.templ", stdout, "Page Title", userArray, userArrayLength); + + +size_t length = sizeTemplate("templates/index.html.templ", "Page Title", userArray, userArrayLength); + + +char* string = renderTemplateStr("templates/index.html.templ", "Page Title", userArray, userArrayLength); +free(string); // don't forget to free ``` # Demo