-
Notifications
You must be signed in to change notification settings - Fork 33
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
directly output string instead of a function #117
Comments
It is possible to define a function fn rendertemplate<F>(f: F) -> String {
let mut buf = Vec::new();
f(&mut buf).unwrap(); // Or return a Result<String>
buf
} That can be used as: rendertemplate(|out| templates::hello_html(out, "world")); If the function is made a method of an extension trait for your response type, it could be called as: response.rendertemplate(|out| templates::hello_html(out, "world")); This is done in the |
Is it possible to add a feature such that templates to return string instead of function if the feature flag is enabled This makes it easy to onboard to new frameworks. More info at salvo-rs/salvo#147 (comment).
//cc @chrislearn
The text was updated successfully, but these errors were encountered: