Skip to content

Passing local variables while including a template? #54

@saurabhnanda

Description

@saurabhnanda

I'm trying to descend a recursive data-structure and recursively render the same template [1] Forget the recursive part, I'm unable to pass local variables to an included template. I've tried the following, and nothing works:

{% include "includes/toc.html" with tocItems = page.toc %}
{% with tocItems = page.toc %}
  {% include "includes/toc.html" %}
{% endwith %}
{% scope %}
  {% set tocItems = page.toc %}
  {% include "includes/toc.html" %}
{% endscope %}

[1] I'm trying to generate a page's TOC -- which is why the recursion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions