如何在Jinja2中做一会儿(x< y) [英] How to do a while ( x < y ) in jinja2

查看:80
本文介绍了如何在Jinja2中做一会儿(x< y)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在Jinja2中做一会儿(x< y)吗? 我看过jinja2文档,似乎它们仅支持对声明的数组变量进行循环,而完全不支持while().

How should I do a while ( x < y ) in jinja2? I've seen the jinja2 docs, it seems like they only support for loop for a declared variable of array and while() is not supported at all.

推荐答案

我认为与 Jinja2 最接近的选择是将 for range :

I think your closest alternative with Jinja2 would be to use a for with range:

  {% range number from 3 to 6 %}
      {{ number }}
      (...)
  {% endrange %}

您可以从程序中传递变量以在循环中使用它们.

And you can pass the variables from your program to use them in the loop.

这篇关于如何在Jinja2中做一会儿(x&lt; y)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆