- Flask Framework Cookbook(Second Edition)
- Shalabh Aggarwal
- 80字
- 2021-06-24 13:58:03
Creating a custom macro for forms
Macros allow us to write reusable pieces of HTML blocks. They are analogous to functions in regular programming languages. We can pass arguments to macros as we do to functions in Python, and we can then use them to process an HTML block. Macros can be called any number of times, and the output will vary as per the logic inside them. In this recipe, let's understand how to write a macro in Jinja2.