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/