question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why not just use {% include ... %} ?

See original GitHub issue

Can you comment on why this is better than using {% include ... %}? https://jinja.palletsprojects.com/en/3.0.x/templates/#include

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
carlbordumcommented, Mar 31, 2022

With jinja, I believe you can:

{% for v in videos %}
  <div class="video">
    {% with video=v email=user.email %}
      {% include "video.html"%}
    {% endwith %}
  </div>
{% endfor %}
4reactions
mikeckennedycommented, Oct 13, 2021

Hi @nickleman

That will work I think. But it’s just more clumsy. Not too bad for one variable, the example we’ve been discussing needs two:

{% for v in videos %}

<div class="video">
      {% set email = user.email %}
      {% set video = v %}
      {% include "video.html" ignore missing with context %}
</div>

{% endfor %}

What if there is more?

{% for v in videos %}

<div class="video">
      {% set email = user.email %}
      {% set video = v %}
      {% set cat_name = category.category %}
      {% include "video.html" ignore missing with context %}
</div>

{% endfor %}

Does that still feel better than:

{% for v in videos %}

<div class="video">
    {{ render_partial("video.html", video=v, email=user.email, cat_name=category.category) }}
</div>

{% endfor %}

To me, definitely not. But if you don’t like how that looks, then go for the set multiple variables + include. It’s a choice for sure, not a requirement to use this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Why should we use "#include<iostream>" while we are ...
As a way of keeping things organized, c++ provides namespaces. All of the standard library is defined within the namespace called std ....
Read more >
What are the benefits of not including other header files in a ...
It is best (like all rules of thumb there are exceptions) to include only the things you explicitly need. Anything that is not...
Read more >
Why make a header file? Why can't we just include .c file?
Two situations: One, you have one big file you've written perfectly, that takes time to compile, and you want to include it somewhere....
Read more >
Is it wrong to include C/C++ standard libraries that are not ...
When more header files are included ,only the compile time varies but not the execution time. Compilation is a one time process ,hence...
Read more >
Include what you use - GitHub
This puts us in a state where every file includes the headers it needs to declare the symbols that it uses. When every...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found