Skip to content

Latest commit

 

History

History

minijinja-cabi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

minijinja-cabi

Build Status License rustc 1.61.0

minijinja-cabi is a crate that wraps MiniJinja into a C library. This is an experimental and not published crate.

For an example look into hello.c.

#include <minijinja.h>
#include <stdio.h>

int main()
{
    mj_env *env = mj_env_new();

    bool ok = mj_env_add_template(env, "hello", "Hello {{ name }}!");
    mj_value ctx = mj_value_new_object();
    mj_value_set_string_key(&ctx, "name", mj_value_new_string("C-Lang"));

    char *rv = mj_env_render_template(env, "hello", ctx);
    if (!rv) {
        mj_err_print();
    } else {
        printf("%s\n", rv);
        mj_str_free(rv);
    }

    mj_env_free(env);

    return 0;
}

Sponsor

If you like the project and find it useful you can become a sponsor.

License and Links