Friday, May 1, 2026
HomeiOS DevelopmentThe way forward for Leaf and Tau

The way forward for Leaf and Tau

[ad_1]

Which template engine ought to I select for Vapor? What is the distinction between Leaf and Tau? Let me clarify all the things.

Vapor

Leaf

To start with, if you do not know, the Leaf 4 launch incorporates some main syntactical adjustments in comparison with the earlier model. Curly brackets have been changed with the brand new #finish prefix syntax.


This can be a main step ahead, but additionally a breaking change, which means it’s a must to improve your at the moment present Leaf 3 codebase, in any other case your templates will not work. The opposite main change is expounded to template inheritance. The brand new lengthen, export and import key phrases changed the earlier embed and set key phrases, once more.

So appropriate me if I am unsuitable, however this enchancment is like taking a step backward, as a result of in Leaf 2, we had kind of the identical template inheritance API capabilities (import, export, lengthen, and embed). I suppose that this transformation might be complicated for some individuals who have been already aware of the 2nd or the third model of Leaf. (I used to be shocked after I noticed these adjustments.) 😐


I do not wish to criticize this resolution, however these adjustments do not essential deserve a serious model quantity. It isn’t a giant enchancment from a developer (end-user) perspective. The one factor what modified with Leaf 4.0.0 is that we builders have to vary our codebase to make issues work once more, however we have gained nearly zero new options, that I might anticipate from a serious launch.


I used to be very unhappy about this and I can think about that this may make server aspect Swift builders fairly upset. I’ve already missed various options from Leaf, that I might anticipate from a contemporary template engine. Simply check out mustache or handlebars, they’re in fact older, nevertheless it’s price to say that they’ve some far more superior options, that you just nonetheless cannot do in Leaf. 😢


Now, in the midst of the 4.0.0 growth an attention-grabbing factor occurred with Leaf…



Tau

There was a brand new department referred to as Tau (means rebirth) created and maintained by @tdotclare. I jumped the practice and began to make use of this experimental department as an alternative of the primary / dev.

We additionally began to speak rather a lot with tdotclare, since there have been some points, particularly to start with, however lastly I’ve discovered somebody on Vapor’s discord who I might ask about Leaf. He helped me so much and I am extraordinarily grateful, as a result of with out him, the template layer of Feather CMS would not be such an incredible (modular, reusable, extensible) system. 🙏

Lengthy story quick, tdotclare carried out a lot of nice new options for Leaf Tau, the entire system began to appear like as an actual template engine, not simply one thing that you may use to switch key-based variables in a really lengthy output string. (Pardon me, however that is the case with Leaf.) 🙈

We had a imaginative and prescient about the way forward for Tau, the place you may differentiate sorts, create new language components and particular extensions (capabilities, strategies, blocks, contexts) for the duty that you must resolve, in a protected and simple manner. Tau already has all these goodies and much more.

You possibly can outline variables and constants, and the brand new template hierarchy system appears to be extra logical and future proof than another earlier variants of the template inheritance APIs. Lastly, after numerous hours of conversations, feedbacks, testing, and bug squashing, the Tau options have been merged to the primary department and launched beneath the 4.0.0-tau.1 tag.


If you wish to hold utilizing Tau, you need to pin your Swift dependency variations to:
.bundle(url: "https://github.com/vapor/leaf", .precise("4.0.0-tau.1")),
.bundle(url: "https://github.com/vapor/leaf-kit", .precise("1.0.0-tau.1.1")),

Sadly, the Vapor core crew determined to revert these adjustments shortly after the Tau launch with out a detailed rationalization. So far as I do know the primary cause was that the core crew needs to maintain Leaf as a “easy” template engine. Do not get me unsuitable, I am positive with that call, however then it was positively a mistake to formally launch Tau and shortly after take away it similar to that. 😕




The long run

So here is what I used to be desirous about this complete subject in the previous couple of months.

Leaf 4.x

I’ve at all times felt like these new Tau options are manner too good to easily drop them, simply to go together with Leaf. Plus what does the time period “easy” means? Can I anticipate something new in Leaf or is it going to be solely bug fixes solely any more? Is the long run vibrant for Leaf or ought to I merely drop it? 💧

Effectively, sure. I am not going to make use of Leaf once more.

If you’re planning to construct a brand new challenge and also you want a dependable, quick, dynamic template engine with a simply very fundamental (restricted) function set, then you need to think about using Leaf. 🍃


Area Particular Languages

These days everyone seems to be into DSL’s (SwiftUI), so why not use a DSL library, corresponding to HTMLKit or Plot as an alternative of Leaf? If the template engine will not enable me to do extra sooner or later then a DSL can be a manner more sensible choice. It could possibly be extra protected and performant, however in fact we might sacrifice the dynamic nature (you at all times should recompile the complete server code after one thing adjustments), however nonetheless, based mostly on the circumstances, I can solely consider this answer as a greater various.

For those who do not wish to dynamically replace templates and also you’re positive with the “static web site generator” strategy, then I might recommend to make use of a Area Particular Language based mostly template engine.


Tau

It’s a dynamic template engine with a really wealthy function set, that you need to use to construct extra advanced templates. Since Tau is derived from Leaf it implies that the syntax could be very related, so the official Leaf documentation covers just about all the things that it’s a must to find out about it, plus I have already got some good tutorials on my web site about utilizing the brand new options of Tau.

Based mostly on my expertise, I’ll keep on with “Tau”.

It is best to know, that the 4.0.0-tau.1 launch beneath the vapor/leaf repository could be very steady, so you need to use that tag for now if you wish to give an opportunity to Tau.

It’s price to say that Tau might be re-released in a while in a separate repository beneath a model new title. Sadly, I can not give an actual schedule for the transition course of simply but. Hopefully this fashion we are able to keep away from additional confusions and builders can choose the proper instrument for the job.

The Vapor core crew and the authors of Leaf are doing an incredible job. This publish just isn’t meant to hurt them in any manner, however I simply wished to supply some actual rationalization for everybody who was asking me in regards to the present standing of Leaf and Tau. Thanks for understanding this. 🙏



[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments