PloneFormGen header 注入(inject)示例

标签 plone zope ploneformgen

PloneFormGen 允许使用所谓的 Header Injection 将自定义数据注入(inject)网页标题。描述是:

This override field allows you to insert content into the xhtml head. The typical use is to add custom CSS or JavaScript. Specify a TALES expression returning a string. The string will be inserted with no interpretation. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display.

我想知道这种表达式的正确语法是什么..我没有成功使用以下示例

<style type="text/css"> * { color: red !important; } </style>

没有

<style tal:attributes="type:text/css" tal:content="* { color: red !important; }">

没有

<style tal:attributes="type:text/css" tal:content="string:* { color: red !important; }">

没有

<style tal:attributes="type string:text/css" tal:content="string: * { color: red !important; }" />

错误消息只告诉我它有错误..

最佳答案

该字段被解释为 TALES 表达式;该表达式的结果将被插入。您的示例都不是 TALES 表达式;不过,最后 3 个都使用 TALES 表达式作为更大的 TAL 模板语句的一部分。

在您的情况下,您只需要一个 string: 表达式来返回静态结果:

string:<style type="text/css"> * { color: red !important; } </style>

关于PloneFormGen header 注入(inject)示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12196745/

相关文章:

python - 向使用 zope.formlib 构建的 Plone 表单发送 GET 请求

python - 如何创建具有多个模式的 z3c.form?

mysql - Plone 和 Mysql 搜索

Plone 4.1 自定义 PAS 插件(带贴纸)

python - Plone:代理服务器后面的 pypi 特定下载问题 - 无法安装 eggs

plone - 使用 grok 和 Plone 命名适配器?

python - 检查 Plone PythonScript 中的类型

plone - 有没有办法将 PloneFormGen 中的当前数据(作为 .csv 文件)附加到邮件程序?

python - 如何在输入数据时动态增加字段列表以获取更多项目?