0

I have a static theme that contains some json attributes for customizing jquery plugins, like

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

diazo compiler complains about this like

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]

and breaks the rendering.

Is there a way for making this work (beside moving the conf to js)?

simahawk
  • 2,421
  • 1
  • 16
  • 22

3 Answers3

1

It seems the only solution - and that actually make sense - is to split the parameters in more than one data attribute. Like:

data-plugin-directionNav="false"
data-plugin-animation="slide"
data-plugin-slideshow="false"
data-plugin-maxVisibleItems="6"
simahawk
  • 2,421
  • 1
  • 16
  • 22
0

These are TALES expressions. Try starting with 'string:'. You'll need to escape '$' and ';' if you use them.

Check the plone.app.theming page on PyPI; search for "The right hand side is a TALES expression" for the documentation section covering this.

SteveM
  • 6,058
  • 1
  • 16
  • 20
  • I tried this but nothing changed. Same error. I think is meant to work only on theme's parameters but I need that into the static html itself. – simahawk Sep 02 '13 at 07:42
  • I was indeed thinking of theme parameters. Looks like I misunderstood the problem. – SteveM Sep 02 '13 at 14:04
0

Braces must be escaped, i.e. {{ and }} otherwise the xslt-engine will try to eval/compile the expressin in the AVT.

Furthermore, the attribute value must be enclosed in double quotes "..." and the dict values in single quotes '...' like the following:

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

this will transform into

attributename="{xyz:'abc'}"

Remember: when you load the html-template without diazo (i.e. directly from your filesystem) you must not escape the braces. Otherwise your plugin eventually will not treat it as a json-string.

wolfrevo
  • 6,651
  • 2
  • 26
  • 38