I have the following express route:
var data = [
{
id: 1,
title: 'aide-memoire'
},
{
id:2,
title: 'apres moi'
}
];
app.get('/', function (req, res) {
res.render('photo/list', {
data: data
});
});
In my JADE template I'm getting that data like the following:
!!!5
html
head
body
script
var data = !{JSON.stringify(calculates)};
But I get that data array on a client like this:
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="text/javascript">
var data = [
{ "id":1, "title": 'aide-memoire'},
{ "id":2, "title": 'apres moi'}
];
</script>
</body>
</html>
But I need to encode non-ASCII characters as \uXXXX sequences like the following:
[
{"id":1, "title": "aide-m%E9moire"},
{"id":2, "title": "apr%E8s%20moi"}
]
How can I do that in express/jade?