Escaping single quote with leaflet usage

I have the following macro…

\define mapping(maptype, filter)
<$leafmap tileControl tile='$maptype$' places='{"filter":"$filter$"}' cluster='30' />
\end

The filter passed to mapping is a generated list of tiddlers. Eg.

[[London, England]] [[St. James' Church]] England

This does not work because of the single quote in the filter and the usage of the leafmap macro.

What is the best way to resolve this?

Thank you.

A robust solution would involve string concatenation to construct the places attribute via filters, or use of another macro to assign the places attribute.

However, triple quotes might do the trick:

\define mapping(maptype, filter)
<$leafmap tileControl tile='$maptype$' places="""{"filter":"$filter$"}""" cluster='30' />
\end
1 Like

The triple quotes, as you provided, did not work. However, my first attempt at constructing a “string concatenation to construct the places attribute” got me to write this:

\define mapping(maptype, filter)
<$set name=placefilter value="""{"filter":"$filter$"}""">
<$leafmap tileControl tile='$maptype$' places=<<placefilter>> cluster='30' />
</$set>
\end

…which worked well. Thank you again.

1 Like