Skip to content
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

[FEATURE] Running the macro from templates #43

Open
rafalschmidt97 opened this issue Jan 23, 2023 · 2 comments
Open

[FEATURE] Running the macro from templates #43

rafalschmidt97 opened this issue Jan 23, 2023 · 2 comments

Comments

@rafalschmidt97
Copy link

rafalschmidt97 commented Jan 23, 2023

Describe the solution you'd like
A clear and concise description of what you want to happen.

Hi, is it possible to run {{ blog_content }} macro from .html instead of .md?

Imagine instead of doing:

home.md

---
template: home.html <-- my custom
title: Blog
---

Hello folks!

{{ blog_content }}

with

home.html

{% extends "main.html" %}
<!-- Content -->
{% block content %}
  {{ page.content }} 
   here will be my custom logic
{% endblock content %}

I would like to move {{ blog_content }} outside of home.md:

home.md

---
template: home.html <-- my custom
title: Blog
---

Hello folks!

with

home.html

{% extends "main.html" %}
<!-- Content -->
{% block content %}
  {{ page.content }} 
   here will be my custom logic
   {{ blog_content }}
{% endblock content %}

I couldn't manage to include the plugin templates (not found):

{% extends "blog.html" %}
{% include "plugins/mkdocs-blogging-plugin/templates/blog.html" %}
@liang2kl
Copy link
Owner

liang2kl commented Feb 11, 2023

For now this is not possible to use this bracket-enclosed phrase inside a template, because {{...}} is for the template to replace the whole phrase with the content of the variable, which does not exist in the environment of the template - {{ blog_content }} is just the magic word for the plugin to find and replace in the markdown file.

One possible solution is to add another syntax for blog_content, for example, [[ blog_content ]], and replace in in the final HTML rather than the markdown. I will be looking into that later.

@liang2kl
Copy link
Owner

And it's not possible to include the template of the blog in your template because they are processed separately and independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants