针对特定用例中 Python Web 开发的最佳模板引擎的建议
对于 Python Web 开发,有大量的模板引擎可供选择。我的工作仅限于一组相当狭窄/特定的用例。对这些的描述可能会向那些对其中许多/大多数具有工作知识的人建议,其中一个更适合我的特定用例。换句话说,这组中可能有一个针对接近我自己的用例的规范进行了优化,如果是这样,我想知道它是什么。
以下是描述这些用例的标准:
服务器端语言是python,但我希望我不需要太多 我的模板中的 python 表达式
我将把它与 python Web 服务器 CherryPy 一起使用并且(可能) Twisted
jQuery 是数据显示的语言 编写库/插件
模板描述用于数据显示的抽象网页 (BI 仪表板,这是一个公平的描述)一旦服务器将数据传送到 模板(响应在先行词上提交的表单选择 页)我只想在网格中显示数据,例如,jQuery 插件 jqgrid,或在图中,例如,中的标准类型之一 Flot
性能至关重要,但范围非常狭窄——仅适用于 数据处理和渲染——我希望网格经常被填充 具有数千个数据行(尽管网格本身将是 分页);同样,这些地块很容易有一千个左右 数据点,但同样,预处理和计算将是 在其他地方完成
很少需要丰富的语法(不需要复杂的多路 分支等)--我更喜欢在 服务器(同样,数据过滤几乎总是由 我用来渲染数据的 jQuery 插件)
同样,用户与显示数据的交互是通过 jQuery 插件提供的本机元素(例如,向上/向下翻页、 排序等)
“设计者友好”的模板并不是很重要(不是因为我 不喜欢设计师,但因为所需的设计工作应该 足够低,以便我什至可以做到。
For Python Web Development, there is a large selection of template engines. My work is limited to a fairly narrow/specific set of use cases. A description of these might suggest to someone who has a working knowledge with many/most of them, that one of them is better suited for my particular use cases. In other words, there might be one among this group that was optimized against a spec close to my own use case, if so i would like to know what it is.
Here are the criteria that describe those uses cases:
server-side language is python, but i hope that i don't need a lot
of python expressions in my templatesi will use it with the python web servers CherryPy and (likely)
TwistedjQuery is is the language in which the data display
libraries/plug-ins are writtenthe templates describe abstract web pages used for data display
(BI Dashboard, is a fair description) once the server delivers the data to the
template (in response to form selections submitted on an antecedent
page) i just want to display the data in a grid, e.g., the jQuery
plug-in jqgrid, or in a plot, e.g., one of the standard types in
Flotperformance is critical, but the scope is very narrow--only for a
data handling and rendering--i expect grids will often be populated
with several thousand data rows (though the grid itself will be
paginated); likewise, the plots could easily have a thousand or so
data points, though again, the pre-processing and computation will be
done elsewherevery little need for a rich syntax (no need for complex multi-way
branching, etc.)--i prefer to do any processiong/computation on the
server (and again, data filtering will almost always be done by the
jQuery plugin i use to render the data)likewise, the user's interaction with the displayed data is through
native elements supplied by the jQuery plug-in (e.g., page up/down,
sort, etc.)a "designer-friendly" template is not really important (not because i
don't like designers, but because the design effort required should
be low enough so that i even i can do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的模板要求非常简单,那么我建议您使用 Python 的内置 String格式化引擎...
If your templating requirements are really simple, then I suggest you to use Python's builtin String Formatting engine...
您可能想看看 Jinja2。它提供模板预编译,允许熟悉的 Python 语法,并且与框架无关。
You may want to take a look at Jinja2. It offers precompilation of templates, allows familiar Python syntax and is framework-agnostic.
Mako, Jinja2、Cheetah 和 Django 模板 引擎都执行此操作。就此而言,此列表中的任何内容都可以工作: http://wiki.python.org/moin/模板化
没有一个需求是特别有趣的。他们不指向任何产品,因为它们非常笼统。
除了这个,它不属于。
这是无关紧要的。任何用户都无法与模板交互。它们与向模板提供数据的网页进行交互。
Mako, Jinja2, Cheetah and the Django template engine all do this. For that matter, anything on this list will work, also: http://wiki.python.org/moin/Templating
None of the requirements is particularly interesting. They don't point to any product because they're very general.
Except this, which doesn't belong.
This is irrelevant. No user can ever interact with the template. They interact with a web page that provides data to the template.