Replies: 7 comments 20 replies
-
|
There is no way to instantiate values of kinds Bytes and Plain with |
Beta Was this translation helpful? Give feedback.
-
|
Would it be possible to add the minijinja/minijinja-cabi/Cargo.toml Line 7 in 607d2de |
Beta Was this translation helpful? Give feedback.
-
|
Concurency with minijinja/minijinja-cabi/src/error.rs Lines 8 to 10 in 607d2de That would an important limitation of any implementation based on it at the moment |
Beta Was this translation helpful? Give feedback.
-
|
Does enabling debugging with minijinja/minijinja-cabi/include/minijinja.h Line 169 in fd06e65 Would it possible to return the error details as a string, mostly the source part could be useful, so it can be accessible through the regular error handling flow? minijinja/minijinja-cabi/include/minijinja.h Line 238 in fd06e65 |
Beta Was this translation helpful? Give feedback.
-
|
Is parsing the string representation of an MJ value the expected way to convert it to a native type with |
Beta Was this translation helpful? Give feedback.
-
|
Would you have any recommendations how to get started with WASM and Rust :: wazero? Target
I had a look at the new |
Beta Was this translation helpful? Give feedback.
-
|
I am seeing a weird issue with The same occurs with Here is a minimal Go reproduction, anything that stands out in the handling of strings? main.gopackage main
// #cgo CFLAGS: -I${SRCDIR}/include
// #cgo LDFLAGS: -L${SRCDIR}/lib -lminijinja_cabi
// #include <stdlib.h>
// #include <minijinja.h>
import "C"
import (
"fmt"
"os"
"unsafe"
)
func main() {
name := "hello"
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
source := C.CString("{% if")
defer C.free(unsafe.Pointer(source))
fmt.Printf("%#x\n", name)
for i := 0; ; i++ {
env := C.mj_env_new()
if ok := C.mj_env_add_template(env, cName, source); ok {
panic("add template should fail")
}
errName := C.GoString(C.mj_err_get_template_name())
if len(errName) > len(name) {
fmt.Printf("%#x %d\n", errName, i)
os.Exit(1)
}
C.mj_err_clear()
C.mj_env_free(env)
}
// Output:
// 0x68656c6c6f
// 0x68656c6c6f7f 164549
}attempted C reproduction#include <minijinja.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int main()
{
bool ok;
int i;
const char *name = "hello";
const char *source = "{% if";
for (i = 0;;i++) {
mj_env *env = mj_env_new();
ok = mj_env_add_template(env, name, source);
assert(!ok);
const char *err_name = mj_err_get_template_name();
printf("0x");
for (int i = 0; name[i] != '\0'; i++) {
printf("%x", (unsigned char)err_name[i]);
}
printf(" %d\n", i);
assert(strlen(err_name) == strlen(name));
mj_err_clear();
mj_env_free(env);
}
return 0;
// Output:
// [...]
// 0x68656c6c6f 1210956
// 0x68656c6c6f 1210957
// 0x68656c6c6f 1210958
// 0x68656c6c6f 1210959
// [...]
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there! 👋
Another awesome library as always ❤️
I would be interested in having Go bindings for MiniJinja, the main use case would be AI Chat templates at the moment.
I started the work here: maxbrunet/minijinja-go.
And the API reference can be found here: pkg.go.dev/github.com/maxbrunet/minijinja-go/v2
There are a few options to choose from to integrate a Rust library with Go:
Support for multiple implementations could be considered with
a common interface and "drivers" similar to the database/sql packagebuild tags (similar to github.com/wasilibs/go-aho-corasick) for users to choose how to integrate MiniJinja with their application and the related trade-offs if there is no clearly superior implementation in term of performance/maintainability/functionality/ease-of-use...Also not sure if you would be open to having it living in this repo (after a few initial iterations probably), it would (eventually) make it easy to release, it would only require a
minijina-go/v$versionGit tag (note: the leadingvis required). (reference)I am going to add questions and comments below, so they can easily be answered individually at your convenience. 🙂
Beta Was this translation helpful? Give feedback.
All reactions