Topic on Extension talk:Widgets

How to add data inbetween several quotes

6
Fokebox (talkcontribs)

Hello all So at my java code there is a line with information which has quotes and should look like this:

data: [
['Value_name', 12.81], ['Value_name2', 11.55], ['Value_name3', 13.50]
]

And at widget page I do it so:

    data: [
<!--{$data|escape:'quotes'}-->
],

and I put the values at wiki pages like this:

{{#widget:Widget_name
|data = ['Value_name', 12.81], ['Value_name2', 11.55], ['Value_name3', 13.50]
}}

And result in HTML look like this:

data: [
[\'Value_name\', 12.81], [\'Value_name2\', 11.55], [\'Value_name3\', 13.50]
]

How to escape the sign "\", because widget doesn't work in this case?

Cavila (talkcontribs)

I can confirm that dumb quotation marks are not handled correctly, or as you would like to, in Smarty. The output shows the escaped \' rather than '. I haven't tested this myself, but Smarty offers a replace function. This link looks relevant: http://www.smarty.net/forums/viewtopic.php?p=50671

Another possible workaround is to use the widget inside a template and make sure that the template replaces each instance with its html equivalent &#39;.

Cavila (talkcontribs)

Belated update (better late than never): the answer is that you should use 'single quotes' not 'quotes'. I made the same mistake about a year ago, based on some old documentation, but then visited the Smarty website and found that the syntax was simply incorrect.

Fokebox (talkcontribs)

I did‘t get what you mean, could you five an example with provided above widget?

Cavila (talkcontribs)

Don't use {$data|escape:'quotes'} but {$data|escape:'single quotes'}. That's all.

Fokebox (talkcontribs)

Thank you, I try

Reply to "How to add data inbetween several quotes"