We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is it possible use response to render html string?
macOS 10.15.6 Xcode 11.6 Swift 5.2.4
app.router.post("/some/path", handler: post) func post(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws { . . let html = try response.renderHTML("My.stencil", context: context) try response.send(json: ["status": true, "html": html]).status(.OK).end() }
public func renderHTML(_ resource: String, context: [String: Any], options: RenderingOptions = NullRenderingOptions()) throws -> String { guard let router = getRouterThatCanRender(resource: resource) else { throw TemplatingError.noTemplateEngineForExtension(extension: "") } return try router.render(template: resource, context: context, options: options) }
The text was updated successfully, but these errors were encountered:
I think it should be fine. Just make sure you set your Content-Type to text-html.
https://nocturnalsolutions.gitbooks.io/kitura-book/content/7-templating.html
Sorry, something went wrong.
@dannys42 thanks.
could you adding this function in the future?
@diuming Are you able to make a PR for this feature? It would be great!
No branches or pull requests
Context and Description
Is it possible use response to render html string?
Environment Details
macOS 10.15.6
Xcode 11.6
Swift 5.2.4
Expected
renderHTML(context: options:) in RouterResponse.swift
The text was updated successfully, but these errors were encountered: