Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type safe render method #33

Merged
merged 7 commits into from May 22, 2018
Merged

Add type safe render method #33

merged 7 commits into from May 22, 2018

Conversation

DunnCoding
Copy link
Contributor

@DunnCoding DunnCoding commented May 10, 2018

Description

Adds an implementation for the new type safe rendering method.

Copy link
Contributor

@ianpartridge ianpartridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the other PRs but otherwise this looks good.

Package.swift Outdated
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura-TemplateEngine.git", majorVersion: 1, minor: 7),
.Package(url: "https://github.com/kylef/Stencil.git", majorVersion: 0, minor: 10)
.package(url: "https://github.com/IBM-Swift/Kitura-TemplateEngine.git", .branch("master")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: need updating once we have a tag.

throw StencilTemplateEngineError.unableToCastJSONToDict
}

json = dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not guard let json = try... above, then you wouldn't need this line?

@@ -50,6 +64,39 @@ public class StencilTemplateEngine: TemplateEngine {
let environment = Environment(loader: loader, extensions: [`extension`])
var context = context
context["loader"] = loader
return try environment.renderTemplate(name: templateName, context: context)
do {
let result = try environment.renderTemplate(name: templateName, context: context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be return try environment.render... like it was before?

// Thrown when unable to encode the Encodable value provided to data.
case unableToEncodeValue(value: Encodable)

// Thrown when GRMustache fails to render the context with the given template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GRMustache?

@ianpartridge ianpartridge merged commit 1b66e77 into Kitura:master May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants