aWebDeveloper
aWebDeveloper

Reputation: 38432

include a template inside another but with extend

Here is what i want

tmpl1.jinja

{% for x in List %}
    {% set User = List[x] %}
    {% include 'tmpl2.jinja' %}
{% endfor %}

tmpl2.jinja

{% extends "tmpl3.jinja" %}    
{% block link %}
   <a>share</a>
{% endblock link %}

tmpl3.jinja

User.name
{% block link %}
{% endblock link %}

Basically i have a user block that exists across site with only the action(one or more link but with quiet a few html like image etc) changing. What can i do.

Thanks

Upvotes: 0

Views: 387

Answers (1)

Tigra
Tigra

Reputation: 2631

For the template part everything looks absolutely ok and there should not be problem if what you do is what you showed.

Is Your list is dict() or actually list()?

Because your problem is here:

{% for x in List %}
    {% set User = List[x] %}

This syntax will work only if List is dictionary.

In case of list you should write:

{% for x in List %}
    {% set User = x %}

Upvotes: 2

Related Questions