From 5d66c96a190a396a1535c89bed4e33c2a005fe8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Thu, 24 Mar 2022 01:04:02 +0300 Subject: Initial commit Basically it works, just needs some polishing and maybe a couple of features that I could actually use. Also probably better docs. Not sure if it will be of use to anybody besides me. --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..21ecb18 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# roscha + +A jinja inspired template engine written in C11. Why would I do something like +this? Because I needed a template engine I could use in C programs, and for the +lulz, of course. + +Probably not the best in terms of performance and especially features, but it +gets the job done. + +## How to use + +All the functions and structures that are needed to use roscha are in +`include/roscha.h`, `include/object.h`, `include/hmap.h`, `include/vector.h`, +and `include/slice.h`. + +Basically you initialize roscha with `roscha_init()`, then create a new +environment where all the templates and variables will be with +`roscha_env_new()` add some templates, e.g. you can load them from a dir with +the `roscha_env_load_dir(env, dir)` function, add some variables to `env->vars` +hashmap and render a template running `roscha_env_render(env, template_name)`. + +All variables used inside roscha are wrapped around a reference counted +structure called `roscha_object` that also contains the type information needed +by roscha. You should increment and decrement the reference count appropriately +using the functions `roscha_object_ref(object)` and +`roscha_object_unref(object)` accordingly. + +After using roscha you should free everything related to roscha by decrementing +the reference counts, destroying the `struct roscha_env *` environment, and +calling `roscha_deinit()`. + +## TODO + +* Better document this... or not if nobody else uses? +* Probably fix some bugs that are currently hidden. +* k, v arguments in for...in loops over hashmaps +* Other stuff like space trimming -- cgit v1.2.3