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
Conversation
There was a problem hiding this 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")), |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GRMustache?
Description
Adds an implementation for the new type safe rendering method.