Bottlepy - How To Access Bottle Arguments {{var}} From Javascript?
I'm developing a template that will be included into a larger template, and for some reason the template is not accepting any arguments in Javascript. Everything is fine if the ar
Solution 1:
As @dandavis pointed out in the comment, the proper way to reference the argument in javascript is to put it in a quote:
test.tpl:
<p>from html: {{arg}}</p><scripttype="text/javascript">window.alert("from script "+"{{arg}}");
</script>
Output:
from script somevalue
Without the quotation mark, what JavaScript actually sees is a string followed by a variable called some value, which is not cannot be concatenated with a string literal. This is how my original code looks like to the browser:
window.alert("from script " + some value);
which is wrong.
Post a Comment for "Bottlepy - How To Access Bottle Arguments {{var}} From Javascript?"