Skip to content

Commit

Permalink
update readme to include stencil from @kylef
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Feb 9, 2016
1 parent 118bc2f commit 35de6df
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ Route.get("/") { request in
}
```

Or Mustache templates (coming soon).
Or Stencil templates.

`index.mustache`
`index.stencil`

```mustache
<html>
Expand All @@ -95,11 +95,31 @@ Or Mustache templates (coming soon).

```swift
Route.get("/") { request in
return View(path: "index.mustache", ["message": "Hello"])
return View(path: "index.stencil", context: ["message": "Hello"])
}
```

Just put the View file in the `Resources` folder at the root of your project and it will be served.
If you have `VaporStencil` added, just put the View file in the `Resources` folder at the root of your project and it will be served.

#### Stencil

To add `VaporStencil`, add the following package to your `Package.swift`.

`Package.swift`
```swift
.Package(url: "https://github.com/tannernelson/vapor-stencil.git", majorVersion: 0)
```

Then set the `StencilRenderer()` on your `View.renderers` for whatever file extensions you would like to be rendered as `Stencil` templates.

`main.swift`
```swift
import VaporStencil

//set the stencil renderer
//for all .stencil files
View.renderers[".stencil"] = StencilRenderer()
```

### Response

Expand Down

0 comments on commit 35de6df

Please sign in to comment.