Without getting in to too much detail and without people getting too hung up on it.
The variable backup currency for this case is equal to $.
I'm using Chrome V8 in the section where the variable is passed to the HTML so I can use basic Javascript functions there but NO jQuery.
I'm passing a variable into the HTML via Template Toolkit like so:
var backupcurrency = [% backupcurrency %];
Then in my JS:
var temp = backupcurrency + '';
console.log(typeof(temp));
console.log(temp);
The output from this is that temp is a string but the value of temp is NOT '$' and instead for the value I get:
function (a,b){return new e.fn.init(a,b,h)}
I'm thinking maybe I can append to the string in the Chrome v8 step so that the dollar sign is escaped but I should be able to do that in the Jquery anyway.
Now I know this has to do with using Jquery but how do I literally print the $ - dollar sign AND deal with the case that the currency is equal to the dollar sign because if the variable is equal to £ or € I don't want those user's having issues?
Here is the code I want to use the variable in (again high level to avoid any confusion)
HTML:
<div id="upsell"></div>
JS:
var prod = "<div id='upselltext'><h6>Price: " + temp + backupvalue + "/year</h6></div>";
$('#upsell').append(prod);
backup value is a number, in this case '12.50'
EDIT:
Ok solved this by using JSON.stringify() on the variable before it was passed to the HTML
stash({backupcurrency: JSON.stringify(backupcurrency), backupvalue: backupvalue });
then the HTML remains the same but instead it is recognised as a character by jquery.
I don't know anything about Template Toolkit, but if '$
' (with space character) works, then try '$
' (with semicolon instead of space).