gpt4 book ai didi

python - 类似于 thymeleaf "natural templates"for jinja2/python/django 的模板解决方案?

转载 作者:太空狗 更新时间:2023-10-30 01:32:30 25 4
gpt4 key购买 nike

我使用 我对此很满意,只是我想与一个做 CSS 和 HTML 的前端程序员合作,而不是强制他运行整个堆栈。

理想的模板是在不使用后端时呈现虚拟数据而不是动态数据,这样设计人员就可以仅使用浏览器和他的开发环境来处理图形和布局。

Java 有模板引擎 它可以将模板呈现为纯 html,即使它们具有从后端和框架获取数据的标签。

jinja2、django 或 python 有类似的东西吗?

最佳答案

模板属性语言 (TAL) 和 Zope 页面模板 (ZPT)

我不确定这是什么时候出现的,但我已经监视这个空间好几年了,今天是我第一次注意到有一个 Python 版本的 TAL,我几年前在 PHPTAL 中确实遇到过它,并且与 Thymeleaf 非常相似。

示例代码:

<p tal:content="user/getUserName">Placeholder</p>

<table>
<tr tal:repeat="item context/cart">
<td tal:content="repeat/item/number">1</td>
<td tal:content="item/description">Widget</td>
<td tal:content="item/price">$1.50</td>
</tr>
</table>

更多例子在 https://pagetemplates.readthedocs.io/en/latest/tal.html

reference implementation of TAL in Python可以安装

pip install zope.pagetemplate

还有other implementations包括以性能为导向的分支和其他编程语言的端口。

关于python - 类似于 thymeleaf "natural templates"for jinja2/python/django 的模板解决方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41323954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com