0

我有一个静态主题,其中包含一些用于自定义 jquery 插件的 json 属性,例如

data-plugin-options='{"directionNav":false, "animation":"slide", "slideshow": false, "maxVisibleItems": 6}'

重氮编译器抱怨这个像

Invalid expression [0:0]
compilation error, element 'div' [400:0]
Attribute 'data-plugin-options': Failed to compile the expression ''directionNav':false, 'animation':'slide', 'slideshow': false, 'maxVisibleItems': 6' in the AVT. [0:0]
Invalid expression [0:0]
compilation error, element 'div' [445:0]
Attribute 'data-plugin-options': Failed to compile the expression ''directionNav':false, 'animation':'slide'' in the AVT. [0:0]
Invalid expression [0:0]
compilation error, element 'div' [512:0]
Attribute 'data-plugin-options': Failed to compile the expression ''controlNav':false, 'slideshow': false, 'animationLoop': true, 'animation':'slide'' in the AVT. [0:0]

并打破渲染。

有没有办法使这项工作(除了将 conf 移动到 js 之外)?

4

3 回答 3

1

似乎唯一的解决方案——实际上是有意义的——是将参数拆分为多个data属性。像:

data-plugin-directionNav="false"
data-plugin-animation="slide"
data-plugin-slideshow="false"
data-plugin-maxVisibleItems="6"
于 2013-09-03T07:03:42.507 回答
0

这些是 TALES 表达式。尝试从“字符串:”开始。您需要转义 '$' 和 ';' 如果你使用它们。

检查 PyPI 上的plone.app.theming页面;在涵盖此内容的文档部分中搜索“右手边是一个故事表达式”。

于 2013-08-29T17:14:27.550 回答
0

大括号必须转义,{{否则}}xslt 引擎将尝试评估/编译 AVT 中的表达式。

此外,属性值必须用双引号括起来"……"而 dict 值必须用单引号括起来'……'如下所示:

attributename="{{xyz:'abc'}}"

这将转变为

attributename="{xyz:'abc'}"

请记住:当您加载不带重氮的 ht​​ml 模板时(即直接从您的文件系统中),您不能转义大括号。否则,您的插件最终不会将其视为 json-string。

于 2013-11-26T11:41:11.757 回答