jinja macro import

Solutions on MaxInterview for jinja macro import by the best coders in the world

showing results for - "jinja macro import"
Kylian
06 Jun 2019
1# This is how you define the macro
2# This is in the file "Input_Block"
3{% macro input(name, value='', type='text', size=20) -%}
4    <input type="{{ type }}" name="{{ name }}" value="{{
5        value|e }}" size="{{ size }}">
6{%- endmacro %}
7
8# Import from the file and set a contextual name
9{% import 'Input_Block' as emailBlock %}
10{{ emailBlock.input("user input") }}