Forum Discussion

Claudius's avatar
4 years ago

How to escape dashes in component parameter names?

I am trying to include the Khoros masonry component at a certain location in my own custom component and pass some parameters to support infite scroll like this:

<@component id="media.widget.masonry-grid" li-infinite-scroll="true" li-pagination="false"/>

Unfortunately, this results in the dashes of the component's parameters triggering the following

ParseException:Syntax error in template "preview" in line 802, column 50:
Encountered "-", but was expecting:
    "="

Is there any way to escape these component parameter names to prevent this? I already was browsing the Freemarker documentation in vain for any hints of that 😐

  • After I ran into this problem again I did some further digging in the Freemarker manual and found the answer in the section "Top-level variables": Dashes, dots and colons in parameter names need to be escape using a preceeding slash, e.g. I got my code working by changing it to

    <@component id="media.widget.masonry-grid" li\-infinite\-scroll="true" li\-pagination="false"/>
  • I think you may have a line break after the "li-infinite-". The error message is saying they are expecting a "=", it means you have an incomplete xml sentence. You can try to delete everything and open a text editor and type them in by hand.

    Sometimes we tried to copy the code from Khoros doc. But it may have unexpected character hidden in it. Just delete everything, and type the code in, then you may be able to fix it.

  • Claudius 

     

    You need to pass them as a parameter

    <@component id="media.widget.masonry-grid" param="li-infinite-scroll='true' li-pagination='false'"/>

     

    Should do what you want it to do.