Skip to content

Nesting resusable components into HTML file. #2992

@Propfend

Description

@Propfend

I have some reusable components, they are macros but i cant nest them, i noticied that by trying to example:

{% extends "base.html" %}
{% import "macros/ryoza.html" as ryoza %}
{% import "macros/content_layout.html" as content_layout %}

{% block content %}
{% call content_layout::content_layout() %}
    <h1>Blog posts</h1>
    <div>
      <ul>
        {% for page in section.pages %}
          <li>{{ page.date }} - <a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
        {% endfor %}
      </ul>
    </div>

    {% call ryoza::ryoza() %}
      <p>I also have <a href="https://medium.com/@mellomello2030" class="active" target="_blank">Medium articles</a>:</p>
    {% endcall %}
{% endcall %}
{% endblock content %}

but getting the error:

Error: Failed to serve the site
Error: Error parsing templates from the /templates directory
Error: Reason: 
* Failed to parse "/home/ryoza/programming/website2/templates/blog.html"
 --> 6:1
  |
6 | {% call content_layout::content_layout() %}
  | ^---
  |
  = unexpected tag; expected an endblock tag (`{% endblock block_name %}` or some content
* Failed to parse "/home/ryoza/programming/website2/templates/index.html"
 --> 6:1
  |
6 | {% call content_layout::content_layout() %}
  | ^---
  |
  = unexpected tag; expected an endblock tag (`{% endblock block_name %}` or some content

I dont necessrily want macros, just some way to have reusable components and i can nest them in the body like this. Passing a macros as anothr parameter is not enough, i want to choose where the passed macro will be rendered, like in the example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions