【问题标题】:Diazo theme with json attributes error: "Attribute 'data-plugin-options': Failed to compile the expression"带有 json 属性错误的重氮主题:“属性 'data-plugin-options': 无法编译表达式”
【发布时间】:2013-08-28 15:43:12
【问题描述】:

我有一个静态主题,其中包含一些用于自定义 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 之外)?

【问题讨论】:

  • 我们能看到更大的静态主题sn-p吗?

标签: json attributes plone theming diazo


【解决方案1】:

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

data-plugin-directionNav="false"
data-plugin-animation="slide"
data-plugin-slideshow="false"
data-plugin-maxVisibleItems="6"

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

    • 我试过了,但没有任何改变。同样的错误。我认为这仅适用于主题的参数,但我需要将其用于静态 html 本身。
    • 我确实在考虑主题参数。看起来我误解了这个问题。
    【解决方案3】:

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

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

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

    这会变成

    attributename="{xyz:'abc'}"

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-19
      • 2021-06-18
      • 2018-03-07
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-08
      相关资源
      最近更新 更多