Jinja2 Documentation Release 2.10useful if one wants to access exported template variables from the Python layer: >>> t = Template('{% macro foo() %}42{% endmacro %}23') >>> str(t.module) '23' >>> t.module.foo() == u'42' True This attribute reusable functions to not repeat yourself (“DRY”). Here’s a small example of a macro that renders a form element: 60 {% macro input(name, value='', type='text', size=20) -%} {%- endmacro %} The macro can then be called like a function in the namespace:{{ input('username') }}
{{ input('password', type='password') }}
If the macro was defined in a different0 码力 | 148 页 | 475.08 KB | 1 年前3
Flask Documentation (1.1.x)this mean for you? If you have a macro you want to import, that needs to access the request object you have two possibilities: 1. you explicitly pass the request to the macro as parameter, or the attribute object you are interested in. 2. you import the macro “with context”. Importing with context looks like this: {% from '_helpers.html' import my_macro with context %} Standard Filters Flask provides even nicer, we can write a macro that renders a field with label and a list of errors if there are any. Here’s an example _formhelpers.html template with such a macro: {% macro render_field(field) %}0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)this mean for you? If you have a macro you want to import, that needs to access the request object you have two possibilities: 1. you explicitly pass the request to the macro as parameter, or the attribute object you are interested in. 2. you import the macro “with context”. Importing with context looks like this: {% from '_helpers.html' import my_macro with context %} 1.6.3 Standard Filters Flask provides even nicer, we can write a macro that renders a field with label and a list of errors if there are any. Here’s an example _formhelpers.html template with such a macro: {% macro render_field(field) %}- {{
0 码力 | 291 页 | 1.25 MB | 1 年前3
MuPDF 1.22.0 Documentation(using fz_throw, or fz_rethrow). } The fz_always block is optional, and can safely be omitted. The macro based nature of this system has 3 main limitations: Never return from within try (or ‘goto’ or longjmp process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the exception fz_catch(ctx) { // This block is only executed when recovering from an exception. } Since the fz_try macro is based on setjmp, the same conditions that apply to local variables in the presence of setjmp apply0 码力 | 175 页 | 698.87 KB | 8 月前3
MuPDF 1.23.0 Documentation(using fz_throw, or fz_rethrow). } The fz_always block is optional, and can safely be omitted. The macro based nature of this system has 3 main limitations: Never return from within try (or ‘goto’ or longjmp process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the exception fz_catch(ctx) { // This block is only executed when recovering from an exception. } Since the fz_try macro is based on setjmp, the same conditions that apply to local variables in the presence of setjmp apply0 码力 | 245 页 | 817.74 KB | 8 月前3
MuPDF 1.25.0 Documentation(using fz_throw, or fz_rethrow). } The fz_always block is optional, and can safely be omitted. The macro based nature of this system has 3 main limitations: Never return from within try (or ‘goto’ or longjmp process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the exception fz_catch(ctx) { // This block is only executed when recovering from an exception. } Since the fz_try macro is based on setjmp, the same conditions that apply to local variables in the presence of setjmp apply0 码力 | 259 页 | 1.11 MB | 8 月前3
MuPDF 1.24.0 Documentation(using fz_throw, or fz_rethrow). } The fz_always block is optional, and can safely be omitted. The macro based nature of this system has 3 main limitations: Never return from within try (or ‘goto’ or longjmp process of throwing that excep- tion. As a way of mitigating this problem, we provide a fz_var() macro that tells the compiler to ensure that that variable is not unset by the act of throwing the exception fz_catch(ctx) { // This block is only executed when recovering from an exception. } Since the fz_try macro is based on setjmp, the same conditions that apply to local variables in the presence of setjmp apply0 码力 | 249 页 | 830.15 KB | 8 月前3
Celery 3.1 Documentationsupports simple variable substitutions, so if the current hostname is george.example.com then the %h macro will expand into that: $ celery worker -n worker1@%h worker1@george.example.com The available substitutions0 码力 | 607 页 | 2.27 MB | 1 年前3
Celery 3.1 Documentationsupports simple variable substitutions, so if the current hostname is george.example.com then the %h macro will expand into that: $ celery worker -n worker1@%h worker1@george.example.com The available substitutions0 码力 | 887 页 | 1.22 MB | 1 年前3
Celery 3.0 Documentationsupports simple variable substitutions, so if the current host-name is george.example.com then the %h macro will expand into that: $ celery worker -n worker1@%h worker1@george.example.com The available substitutions0 码力 | 703 页 | 2.60 MB | 1 年前3
共 60 条
- 1
- 2
- 3
- 4
- 5
- 6













