Announcing: FAR Find And Replace: a dead-simple string template engine

Have you ever wanted a string templating engine in Rust that has basically no features? Well, your dreams have now come true! Let me introduce you to Find And Replace (FAR): a string template engine with basically no features. I'll start with a feature comparison with a more popular templating engine:

Feature Jinja2 FAR Finding and replacing Yes Yes High performance Yes Maybe Easy to debug Yes Maybe Template inheritance Yes No Comments Yes No Control structures Yes No Sandboxed execution environment Yes No Automatic HTML escaping Yes No Configurable syntax Yes No Optional ahead-of-time compilation Yes No And many, many others Yes No

As you can see, this is far simpler. (Sorry.) The reasoning for this is twofold. Firstly, implementing all the features of Jinja2 is a lot of work, I wrote FAR in roughly 8 hours. Secondly, It's my opinion that embedding logic in data is a recipe for maintenance chaos. I agree to disagree with you if you're of the opinion that control structures in external templates is a very useful feature. You're probably right, but I personally don't feel like I need it.

(As a side note, control structures in internal templates like maud are fine IMO, because the data is embedded into the code instead of the other way around. You'll pay the price in compilation times though, which is actually one of the main reasons I wrote FAR in the first place.)

"Weird, but alright," you're thinking, "but show me some code already! How would I even use this?"

Excellent question. Now, since I haven't gotten syntax highlighting working on this site yet, and the existing code blocks are hard to read on mobile, I'm just going to link you to the docs instead of copying the examples here. Odds are, you'll probably want to see the function signature (yes, there's only one) and such anyway. After checking out the docs, you may want to know more about how FAR decides to handle errors and other weird edge cases, and that information can be found here.

I'm also using this in "production" here (relevant source code), but it's currently a very simple use. I've got some ideas about changing the site's colorscheme based on URL parameters though, so watch out for that. Anyway.

Thanks for checking out FAR! If you've got any ideas, questions, or concerns, there's a Matrix room for discussion at #users:typ3.tech, or of course the reddit thread.