-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template inconsistency C# and Extension #112
Comments
To move forward, I'm using a custom version of Scriban where I added support for the missing filters that I'm currently using and the |
Yeah - we've been noodling over implementing an "uber" template language just for these things so all the languages can be unified. In general, you can override the template language and parser mechanism with custom invokers (here's the Liquid one in the new Core runtime we are working on). Would love your thoughts on how we might move forward on this! |
I was also looking for options and there is no template with logic that works across python, c# and JS. Possible solutions I see are:
|
I'm now using Jinja2Cpp in my c# runtime. My c# runtime only needs to worry about parsing and rendering the template, the execution is done in another part of the code. This works a lot better now. Still, because you are using nunjucks in the extensions, there are other unexpected surprises because nunjucks uses the JS engine for expression evaluation, so empty Objects and Arrays evaluate to true, while in Python they are falsy. After looking for a lib in JS that actually replicates Jinja2 behavior, I found this from huggingface. It has MIT license and it does replicate Jinja2 behavior. They say it is a minimalist implementation, but it seems to be fairly complete. So far, the only missing thing I noticed is the lack of whitespace management. |
OH! - Maybe we can add this as an invoker in the new Core runtime?? |
This is the C wrapper I built and currently using https://github.com/injeniero/jinja2c |
I have been using Prompty to write the prompts for our C# Unity game. A template that does work in VS does not work in c#. After some research, I noticed the problem is the Template engine used.
On VS the extension is using nunjucks while the C# runtime is using scriban with support for (liquid)[https://shopify.github.io/liquid/]. So the problem is all of those template engines share a basic template grammar, but behavior and operators are all over the place.
A few examples:
length
, while liquid only hassize
.| join(", ")
, while liquid| join: ", "
not
unary operator, while liquid does not.I have not used python runtime, but I checked it is using jinja2 which I'm sure has its own different behaviors.
The text was updated successfully, but these errors were encountered: