Welcome to zap Discussions! #1
Replies: 3 comments 1 reply
-
Hi Rene, See you at the conf. |
Beta Was this translation helpful? Give feedback.
-
There are many templating engines but I'll broadly categorize them into two categories:
As someone who prefer to see HTML/JavaScript directly, I prefer option 2. Hence the reason for jinja2 even though mustache is part of facil.io. |
Beta Was this translation helpful? Give feedback.
-
Hi Ed (I hope I got your name right), Awesome! That's great to hear! I love jinja2 templates, used them all the time in my python projects. But since I needed to make progress on zap, and facil.io already had mustache templating, I decided that it was easier to just zig-wrap the mustache stuff than trying to integrate another codebase. I checked that mustache supported all the primitives that I needed for conditionals and loops in my JSON templates, which further confirmed me in that decision. But if you manage to ziggify a jinja2 templating codebase, that would be awesome! I would integrate it into zap but I guess it would be more valuable to other projects as a standalone lib. Another reason why I chose the built-in mustache code: I don't need to make copies of string slices. Many C libs suffer from the problem that they use C strings which require 0-termination. When my string is a view into a buffer, there is no 0-termination byte at the end. So I'd need to make a copy that is 1 byte longer than my slice and contains the trailing 0. Watch out for that. It's not the end of the world but I presume that template-heavy apps might take a significant performance hit from copying strings around all the time, depending on what else they do. However, if the alternative would be: no jinja2, I would happily take the perf hit and figure out how to modify the C code later. Looking forward to seeing you at the conference, too! -Rene |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions