问题标签 [template-tal]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
331 浏览

python - 使用 TAL/Chameleon 填充表单字段

我在 Python 中使用 Chameleon 来渲染我的模板。

假设我想使用 POST/GET 数据填充表单字段:

问题是如果 request.params 没有键“foo”,我会得到一个错误。如果键不存在而不是抛出错误,让 value="" 为空的最简单方法是什么?

0 投票
1 回答
435 浏览

python - 这个 ZPT 模板有什么问题?

我正在开发的 Python 网站中使用 Chameleon。这是一段代码:

但由于某种原因,我总是收到语法错误:

我看不出我做错了什么。有什么帮助吗?

0 投票
1 回答
1223 浏览

view - 如何检查 php 关联数组的键是否等于 phptal 条件中定义的变量?

我有这个问题,我的 phptal 视图有一个名为 data 的变量,它是一个关联数组。

假设我的键 M01 M02 和 M03没有按特定顺序,我必须打印给用户查看键 M02 未引用的所有数据。

我怎样才能做到这一点?提前致谢

马可

更新:我忘了说我不能编辑调用视图的代码。

0 投票
1 回答
866 浏览

python - 我的变色龙模板如何接受来自金字塔框架的消息闪烁?

我正在学习金字塔,似乎他们正试图让人们使用变色龙而不是 mako,所以我想我会给变色龙一个机会。到目前为止我喜欢它,我可以在模板中做一些基本的事情,比如 if 和 for 循环,但我不确定如何让消息闪烁出现。

在金字塔教程中,他们在待办事项列表中执行此操作,但在wiki示例中,他们没有。根据有关会话的说明并以 todolist 教程为例,我已经能够让我的应用程序创建消息,但我无法在我的模板中接收它们。简而言之,我想知道变色龙是否有相当于这个 mako 代码:

0 投票
2 回答
2537 浏览

html - ParseError: Unexpected end tag - 如何清理 html 标签?

我开始学习网络开发,并且正在使用带有变色龙的金字塔。我只是在 Dreamweaver 中将一些网站的 html 源代码作为模板,然后将代码复制到 chameleon .pt 文件中。

html 代码在 Dreamweaver 中显示正常,但在金字塔中运行时出现此错误:

我已经尝试过 Dreamweavers 清理功能,它说它删除了 2 个空标签,但我仍然收到此错误。我的回溯都与变色龙中的错误有关,并且没有显示它在我的模板本身中存在问题的特定行。

有没有办法识别发生错误的实际行?

我不确定是否有金字塔或变色龙特定的解决方案,或者是否有在 HTML 标记中查找错误的通用方法。

0 投票
1 回答
333 浏览

plone - 正在做或 TAL 中的其他布尔属性

如何处理可能存在或不存在的属性?示例是 checkbox checked="checked" 或 disabled="disabled" HTML 属性。

涉及到什么样的 tal:attributes 表达式?

0 投票
2 回答
588 浏览

php - Assigning multiple classes to a tag using PHPTAL

I have an array of data I want to output as a UL using PHPTAL (easy) with class attributes supplied by the array (easy), a class attribute for first and for the last element (easy)... all at the same time (hard).

Ie. I want to combine:

with this

and this

This is purely presentational stuff, so I'd rather do it purely in PHPTAL. Is this possible? How?

0 投票
1 回答
746 浏览

plone - 如何在zope页面模板中编写python代码

我对 Zope 和 Plone 很陌生。我正在尝试在 index_html 页面中编写 python 代码。我有人员类型的对象列表,现在我想重新排序它们。所以,我之前有的是:

<tal:listing现在我在...之前有这个python代码

但不知何故,这个人的顺序保持不变。另外,我也不喜欢这种在视图中编写 python 代码的方式。有什么办法可以使用此代码更改列表的顺序?

0 投票
1 回答
220 浏览

plone - zope/plone 如何评估变量?

想象一下这个场景:

我在 Zope 中有一个 ZPT,我在金属块中定义了一个全局变量。
这个变量从这样的表达式中获取它的值

wherenothing可以替换为python:0or python:FalseorNone等​​等。

现在想象到另一个街区,我会做类似的事情

nothing我上面指定的所有内容都在哪里。

现在假设它id没有一个值,因此myVar被采用nothing(或其他可能的值;它根本没有区别)。
我所期望的是,它myVar2具有anotherVar价值,因为anotherVar它具有价值。myVar2但令我大吃一惊的是,我注意到这不是真的,而且很有myVar价值。这意味着nothing

如果我理解发生了什么,我会假设这种语句只控制该变量的存在而不是它的值。

显然,我可以将这种陈述变成一种 Python 的方式,当然,它工作得“很好”(即,正如我所期望的那样)
所以,有人可以证实或反驳我在那里的假设吗?

0 投票
0 回答
765 浏览

error-handling - How to handle errors in Zope page templates

I'm looking for a good way to handle errors in Zope's page templates. What I already know is:

or

or

However, it might be desirable to use a more elaborated error handling method, e.g.

  • to display details depending on certain permissions
  • to log and/or report the error to the maintainers
  • to have an easy way to create some pretty HTML without the need of a lot of code in the template

I had a look at the old Zope documentation page and created a script object like described there (amending the missing colon, of course); however, it won't work (I tried both on-error="here/errHandler" and on-error="here/scripts/errHandler", and I added *args and **kwargs, without success).

I tried to build a browser (on-error="here/@@talerror") for such purposes, and it was used alright, but it didn't seem to get the error object.

I'm using Zope 2.10.7-final and Plone 3.3 (old, I know).

Is there a way to hand over the error object to the browser, or to make the script object work?

P.S., just to get it clear: This is not about sqeezing lots of logic in a template - no sermons about templates and logic, please! My goal is to find the error in existing templates, i.e. which part of the logic (which is implemented somewhere behind the scenes, in browsers etc.) fails in which way. The documented way of using an error script doesn't work for me (maybe I'm missing an important part?), and an error handling browser apparently doesn't have access to the error object.