Server Side Swift with Vapor: Templating with Leaf | Ray Wenderlich

Learn how to use templating in your server side Swift apps using Vapor, an open source server side Swift framework, and Leaf, a templating engine.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4995-server-side-swift-with-vapor-templating-with-leaf
1 Like

This rocks! :smile: Can’t wait for the next one!

Really cool stuff here VAPOR, me too waiting for more …:slight_smile:

Great stuff:) Any plans for Server Side Swit book? I would buy that instantly!

1 Like

@rwenderlich WiIl you cover the ability create custom middleware / vapor packages in the screencast series?

Hi Ray, this is so super cool :slight_smile:, can’t wait for the database tutorial.

Tried using #raw() as described in your tutorial.
Had a problem escaping the # character in a leaf document so # is ignored.

A simple example would be a css color hash in a leaf document

 table tr:nth-child(odd) {
     background-color:  #f1f1f1;
 }
 table tr:nth-child(even) {
     background-color: #ffffff;
 }

See Example: place this in a leaf document

That Node class you use to wrap the dictionary for type safety–is that a Vapor thing or a Swift thing? Is there somewhere I can read more about how that works?

@kelvin_lau @anandk Thanks! More screencasts coming soon :]

@fengson Hm perhaps! If we make one, what would you like to see in the book?

@anthony_lockett I wasn’t planning on it, but could be convinced. What kind of middleware / vapor packages are you interested in learning how to make?

@herpgps I just gave this a try with the raw() tag and it seemed to work OK for me. Can you try this and let me know if it works for you? raw.leaf · GitHub

@kamcma That’s a Vapor thing. The developers of Vapor talk about it a bit in this tech talk: - YouTube

@rwenderlich Well I was planning on writing two middleware modules. One for Authorize.net and one for ShipStation. In the end I would like the Authorize.net one to be just a Merchant middleware in general. But I think if you do just anything it would be beneficial, as my issue is I have no idea where to start.

@anthony_lockett I could make a screencast that shows how to make a basic middleware example - perhaps one that beautifies an error message, or perhaps one that logs the time to perform a request. Would that be useful or are you looking for something different?

@raywenderlich Yes that would be great, just knowing how to start would be extremely beneficial

Thanks Ray, Your example seems to work just fine, so I will take a look at my previous test case, I upgraded to Xcode 8.1 only a few days after seeing your tutorial and over several days have had a few strange things happen when building a new vapor project.
The sources folder contained many more folders than the single “App” folder shown in your video. So I needed to test this on a different machine for comparison.
So I will let you know what I find out

Just saw this on iOS Dev Weekly
https://eject.herokuapp.com/

It’s a vapor app

Thought it might be if interest.

I’d love to see how to build a file and return it to the user.
(I’m wanting to create Wallet/Passbook passes.)

I’ve got an running locally on the machine in just swift, working out the best way to convert to server side swift.

Want to render graphics server side swift?

Thanks for the links and suggestion @alexhedley!