Apologies if this has been asked before, I can only find questions dealing with the reverse scenario (i.e. replacing special characters with html entities)
I need to output special characters as part of a JavaScript array using Craft. Currently the values are output with all special characters replaced by their html equivalent. (e.g.: ampersands are replaced by & )
I have tried restoring the special characters using craft replace but without success.
The following code works to replace text, but does not, for example, replace & with &, or rather perhaps it does not distinguish these values as distinct.
<script>
var myVariable = [{% for value in myArray %}"{{ value|replace('raw-html-entity', 'special-character') }}"{%- if not loop.last -%},{% endif %}{% endfor %}];
</script>
This code is being used for an array which is used for jQuery autocomplete values, so raw html is not appropriate.
Any suggestions appreciated.