Replies: 3 comments 7 replies
-
Writing jinja2 macros (instead of Python ones) seems legitimate to me and I am glad that you are bringing that up. Indeed I would use the So that means your macros would be defined once, in one or more files, and you would want an "auto-import" them on all pages? It is not a shocking idea, but some thought is needed. Are we going to be opinionated about it (I would prefer it, for obvious reasons), or give some freedom?
Better to think about all those questions in advance and choose a simple, sensible approach, than falling later into a rabbit hole 🙂 |
Beta Was this translation helpful? Give feedback.
-
Thanks for your input and it makes sense. In your understanding, would the program copy the strings listed there, and paste them as jinja2 directives at the top of every page? There is still a point that is not clear in my mind: what would be the location of I imagine that jinja2 should have a solution to that problem, but I don't know what it is. 🤔 |
Beta Was this translation helpful? Give feedback.
-
I have done some thinking about it. One possibility, would be to generalize the problem, to have a solution that solves a wide range of problems. 🤔 Why not having one auto-include template file; the plugin would insert that file (as a string) at the top of every markdown page that is being parsed? That file could be called But not only; it could contain any markdown, HTML, or combination that one would need to have insert at the top of every markdown page. I already have a use case, where I would like to have a python macro to be executed at the top of every page. Currently, it is problematic, because I wish to insert it manually in each page. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Hi,
My use case for macroses is to simplify certain html/markdown blocks by creating a macros that generates them using user-provided input. Like shortcodes do.
So I am totally fine with defining macroses using jinja2, and not requiring python interpreter for this.
What I am missing though is defining my macroses in a file that would be loaded by default when mkdocs starts.
Currently I can only do local-to-the-page loading using
import
directive.What would be cool is to have a setting similar to
include_yaml
, e.g.include_macros_files
which takes a list of files where macroses are defined.Beta Was this translation helpful? Give feedback.
All reactions