Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 将变量与字符串串联,并将其设置为新变量_Templates_Jinja2 - Fatal编程技术网

Templates 将变量与字符串串联,并将其设置为新变量

Templates 将变量与字符串串联,并将其设置为新变量,templates,jinja2,Templates,Jinja2,我试图设置一个变量,例如cmd=“echo 25”,但它不起作用 {% set cmd = "echo {{ id }}" %} 请帮助修复它。尝试以下操作: {% set testing = 'it worked' %} {% set another = testing %} {{ another }} 结果: it worked 我发现;) 但它不是一个串联。如何将变量添加到“it worked”?是否需要视图。看这个。 {% set cmd = "echo " ~ id %}

我试图设置一个变量,例如
cmd=“echo 25”
,但它不起作用

{% set cmd = "echo {{ id }}" %}
请帮助修复它。

尝试以下操作:

{% set testing = 'it worked' %}
{% set another = testing %}
{{ another }}
结果:

it worked
我发现;)


但它不是一个串联。如何将变量添加到“it worked”?是否需要视图。看这个。
{% set cmd = "echo " ~ id %}