Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

jinja macro import

# This is how you define the macro
# This is in the file "Input_Block"
{% macro input(name, value='', type='text', size=20) -%}
    <input type="{{ type }}" name="{{ name }}" value="{{
        value|e }}" size="{{ size }}">
{%- endmacro %}

# Import from the file and set a contextual name
{% import 'Input_Block' as emailBlock %}
{{ emailBlock.input("user input") }}
 
PREVIOUS NEXT
Tagged: #jinja #macro #import
ADD COMMENT
Topic
Name
7+8 =