Yaproq - A templating language for Swift

I am closing in on to the first stable release (1.0.0) of the Yaproq open source project (https://github.com/yaproq/yaproq) that is a templating language powered by fast, secure, and powerful Swift language and uses a similar syntax to the Python/Django, Python/Jinja, and PHP/Twig templating languages but more Swifty. I would be really happy if it could contribute to the development of Server-Side Swift to some extent.

Contributing to Yaproq:

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

What you get by contributing:

  • You can gain skills and experience in Swift, Server-Side Swift, and Open Source development in general
  • You can add it to your portfolio so that it can help you get better jobs
  • You can expand your network in Software Development and IT

You can also contribute by starring it (Stargazers · yaproq/yaproq · GitHub) if you like the project and are interested in it but can't contribute in other ways.

11 Likes

This is great man, good work.
I'm looking at switching to this from Leaf for a large project. Do you have a working Vapor integration?

1 Like

Sorry for replying late. Thanks for your interest. What makes you switch from Leaf? I don't have a working Vapor integration yet. I am not sure I will do so because I am working on my own Swift Web Framework at https://chaqmoq.dev where I will spend most of my time and effort. But, I will definitely add support for SwiftNIO projects so that integrating Yaproq to Vapor and other SwiftNIO based projects should be easy. Don't get me wrong. Vapor is an amazing project developed by amazing people. My approach to a Web Framework is different. That's it.

Currently, loading a template file in Yaproq is synchronous because it uses FileManager for loading. Vapor depends on SwiftNIO under the hood and it is recommended to use NonBlockingFileIO to load files. I am going to create a separate repository for that named yaproq-nio to support SwiftNIO based projects. It will depend on yaproq with additional asynchronous APIs.

I am using yaproq for my personal website at https://sukhrobkhakimov.me. I will replace it with yaproq-nio once I finish it. The ETA is until May 15 (within 2 weeks).

Yours has the features I come to expect from a robust templating language, having had a long history with Twig over the years. I feel the syntax has become somewhat of a de facto standard.

My main issue with leaf is having to constantly escape things, as it's easy to invoke the tag/expression syntax through normal use. E.g. color: \#fff;

Lack of SwiftNIO support would be a blocker for me in adopting Yaproq - we serve a lot of requests and it's important that no particular request can block the event loop, even for light file I/O.

As I said, I would add SwiftNIO support within 2 weeks, but not sure about a direct Vapor integration. Leaf's documentation is quite shallow, IMHO. I don't know if they have a common Templating interface where you can add a different implementation. Can you guide me on this? I will check it out and see if I can spend time to add a direct support.

Just a link where I can add another implementation for Vapor’s templating is enough so that you can have a seamless experience just by changing the config and templates.

Sorry to jump in here and derail a thread about Yaproq (and it's great to see more templating options!) - escaping non # tags is no longer required in Leaf as of LeafKit 1.2.0

But great to see another templating language (and web framework) and I hope it does well!

1 Like

Thanks for the info. :+1:

That's good to know @0xTim, thanks!