From ca056a54442efe380c1e8581be20e898a602aff6 Mon Sep 17 00:00:00 2001 From: Carl Downing Date: Mon, 23 Apr 2018 14:03:43 -0700 Subject: [PATCH 1/3] Provide an example for loop variables --- 3.0/docs/leaf/basics.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/3.0/docs/leaf/basics.md b/3.0/docs/leaf/basics.md index 55ff3816..0b243aa8 100644 --- a/3.0/docs/leaf/basics.md +++ b/3.0/docs/leaf/basics.md @@ -155,6 +155,13 @@ Leaf provides some extra variables inside a `#for` loop to give you more informa - The `loop.isLast` variable is true when it's the last iteration. - The `loop.index` variable will be set to the number of the current iteration, counting from 0. +Here's how we could use the loop variables to print just the first name in our array: + +``` +#for(name in team) { + #if(isFirst) {

#(name) is first!

} +} +``` ### Embedding templates From bb201f8611be2496d2444b21ec49262de256895c Mon Sep 17 00:00:00 2001 From: Carl Downing Date: Mon, 23 Apr 2018 14:05:24 -0700 Subject: [PATCH 2/3] I am not immune to my own pettiness --- 3.0/docs/leaf/basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.0/docs/leaf/basics.md b/3.0/docs/leaf/basics.md index 0b243aa8..ca985e71 100644 --- a/3.0/docs/leaf/basics.md +++ b/3.0/docs/leaf/basics.md @@ -155,7 +155,7 @@ Leaf provides some extra variables inside a `#for` loop to give you more informa - The `loop.isLast` variable is true when it's the last iteration. - The `loop.index` variable will be set to the number of the current iteration, counting from 0. -Here's how we could use the loop variables to print just the first name in our array: +Here's how we could use a loop variable to print just the first name in our array: ``` #for(name in team) { From b906bc76e1a9b7f261124ee662100f884445d2ec Mon Sep 17 00:00:00 2001 From: Nate Bird Date: Wed, 25 Apr 2018 16:58:55 -0400 Subject: [PATCH 3/3] Add the required imports for the sample user model Going through this the first time I got tripped up because I forgot the imports at the top. I think adding it to the docs will help other first time users avoid the same mistake I made. --- 3.0/docs/postgresql/fluent.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/3.0/docs/postgresql/fluent.md b/3.0/docs/postgresql/fluent.md index 96778bd8..d2510bc6 100644 --- a/3.0/docs/postgresql/fluent.md +++ b/3.0/docs/postgresql/fluent.md @@ -44,6 +44,9 @@ vapor xcode Now let's create our first `PostgreSQLModel`. Models represent tables in your PostgreSQL database and they are the primary method of interacting with your data. ```swift +import FluentPostgreSQL +import Vapor + /// A simple user. final class User: PostgreSQLModel { /// The unique identifier for this user. @@ -166,4 +169,4 @@ router.get("psql-version") { req -> Future in In the above example, `withPooledConnection(to:)` is used to create a connection to the database identified by `.psql`. This is the default database identifier. See [Fluent → Database](../fluent/database.md#identifier) to learn more. -Once we have the `PostgreSQLConnection`, we can perform a query on it. You can learn more about the methods available in [PostgreSQL → Core](core.md). \ No newline at end of file +Once we have the `PostgreSQLConnection`, we can perform a query on it. You can learn more about the methods available in [PostgreSQL → Core](core.md).