Purpose of this website is to provide examples of Leaf templating engine as a complement to official documentation.
It's powered by Vapor framework and obviously Leaf. Native dark mode support is provided by tailwind.css.
Leaf4Demo requires Swift 5.5 or greater. It can be run in docker container as well so you don't have to install swift on your local machine.
git clone https://github.com/fananek/Leaf4Demo
cd Leaf4Demo
# OPTION 1: run directly on your machine
swift run
# OPTION 2: run in a docker container
docker-compose build
docker-compose up app
If you compare Leaf 4 documentation and our controller, you might notice the controller doesn't call req.view.render("tempalte", context)
directly. It uses req.render("template", context)
instead.
This is a workaround which provides a global context independent on a specific page context. Idea is pretty simple. Request extension wraps provided context and pass it to real renderer.
Any good idea, issue or pull request is welcome. :-)