Replies: 5 comments 5 replies
-
This example shows how you can invoke async functions in your templates: https://github.com/mitsuhiko/minijinja/blob/main/examples/object-using-async/src/main.rs What |
Beta Was this translation helpful? Give feedback.
-
I added a better example here: https://github.com/mitsuhiko/minijinja/blob/main/examples/function-using-async/src/main.rs |
Beta Was this translation helpful? Give feedback.
-
Dear author, hello. I was unsuccessful in trying under activx_web because I wanted the template to be able to automatically reload and also have the add_function to call asynchronous functions. As I have just started working with this engine, it is challenging for beginners to write an example that can both automatically reload templates and call asynchronous functions. If you have time, I hope you can provide an example of activx_web to facilitate our learning. Thank you very much for your prompt reply. Thank you |
Beta Was this translation helpful? Give feedback.
-
After a preliminary attempt, the above code can now obtain asynchronous functions. The {get_config ('title ')} tag can be called in the template, but synchronous functions are no longer available, such as the {{url_for ('index')} tag. |
Beta Was this translation helpful? Give feedback.
-
How can we solve this problem? I came from Java and just learned about Rust. For example, the Freemarker template engine in Java may have different modes. It doesn't differentiate between synchronous and asynchronous custom tags, so it's very convenient to use. The content returned by tags can be customized. I found that the template engine in Rust returns a Value type. I am sending the Java code, do you think it can achieve this effect?
Here is one of the labels
Usage in templates
|
Beta Was this translation helpful? Give feedback.
-
Do you know anything? Because if all templates can call asynchronous data in the form of tags, the controller does not need to call the database, making template development very convenient.
Beta Was this translation helpful? Give feedback.
All reactions