I started a project with a single file "macros.html" that I import
like this in all my templates:
{% import 'macros.html' as m %}
That macros.html file is full of simple reusable blocks of HTML, like
this:
{% macro header() %}
<header>
<h1>..</h1>
</header>
{% endmacro %}
Now after six months, that macros.html file is HUGE.
I want to be able to take the bigger macro definitions out of
macros.html, move them into their own file, and then inside of
macros.html, just import in the different macros, like this:
{% from 'macros/header.html' import header %}
After I changed macros.html to this approach, when I try to use one of
these imported macros, I get an error:
UndefinedError: 'jinja2.environment.TemplateModule object' has no
attribute 'draw_search_bar'
"draw_search_bar" is the name of one of the bigger macros I moved to a
separate file.
Am I doing something wrong? Is this impossible in jinja2?
More generally, any advice on keeping macros/fragments/widgets/
sections of code organized is welcome.
I know I could just import exactly what I need individually, but I
find that a little tedious and error prone.
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.