如何连接django模板中的字符串? [英] How to concatenate strings in django templates?
本文介绍了如何连接django模板中的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在django模板标签中连接字符串,如
I want to concatenate string in django template tag like
{% extend shop/shop_name/base.html %}
这里shop_name是我的变量,我想连接其他路径。
假设我有 shop_name = example.com
Here shop_name is my variable and I want to concatenate this with rest of path.
Suppose I have shop_name=example.com
我想要结果扩展 shop /example.com/base.html
推荐答案
使用:
{% with "shop/"|add:shop_name|add:"/base.html" as template %}
{% include template %}
{% endwith %}
这篇关于如何连接django模板中的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文