-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin incorrectly demands existence of define_env()
in module
#191
Comments
- Now any of the standard functions is accepted (but still files if none is found). - Error message is explicit. - Created the no_module test case to validate that the error is properly raised.
Any standard function is now accepted and the error is now explicit in case none is found:
For good measure, the plugin also traces now the case when no module is found (it's not an error, just in case someone gave a wrong name to the module, or put it in the wrong place). |
This was detected in question #190. |
@Andre601 Could you please check that it works for you now? |
Can confirm that adding the |
Tho, I have to add that in my case, the I want it to add The full code I use, which is basically a copy of the docs: def on_pre_page_macros(env):
footer = "{% import 'game.md' as game %}"
env.markdown += footer I also tried putting it in front of the env.markdown (At the top) in hopes that it may be an issue with order, but no luck there. It simply gives a "game is undefined" error... |
It depends on what your expectancy is of "to work". It is a jinja2 statement, which will be executed immediately after. Indeed, it is executed (at least your error seems to be a jinja2 error). Your import statement seems incorrected formulated (see examples): Shouldn't it be something like the following? {% from 'game.md' import game %} |
I've used jinja2 more than enough to know that Also, my fault for not mentioning that it does work, but I had to add it at the top of the page due to how jinja2 parses things. |
There is a requirement in the plugin.py file that the
define_env()
function should be present in the module file (main.py
).This was correct in the past, but nowadays it could also be
on _pre_page_macros
and others.Workaround
Just add this function to the module file:
The text was updated successfully, but these errors were encountered: