view.jinja
{% extends "layout/defaultlayout.jinja" %}
{% include('details.jinja') %}
defaultlayout.jinja
{% import 'elements/macros.jinja' as html %}
But i am not able to use the macro html in details.jinja without reincluding it
Daniel's answer didn't help me. I had to import the following way
{% from "post_entity.html" import show_post with context %}
Here post_entity.html
was file containing macro with show_post
method
And then used following way:
{{ show_post(post) }}
Here post
is a dictionary sent to template from flask render_template
.
And the macro file
file looked something like this:
post_entity.html
{% macro show_post(post) %}
{{ post.photo_url }}
{{ post.caption }}
{% endmacro %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With