I tried json filter, but I get "json" filter not found error. What I'm I doing wrong?
Error: Filter "json" not found at Object.exports.wrapFilter (......./node_modules/swig/lib/helpers.js:310:11)
<script type="text/javascript">
{{ places|json }}
</script>
object is passed from mongodb
this.displayMainPage = function(req, res, next) {
"use strict";
places.getPlaces(10, function(err, results) {
"use strict";
if (err) return next(err);
return res.render('places_template', {
places: results
});
});
}
Edit: I'm trying to output json to pass to google maps and display the same data in html
For versions of Swig prior to 1.0, the
json
filter was instead namedjson_encode
:And, for compatibility, 1.0 and later keep
json_encode
as an alias ofjson
.Though, you should also consider upgrading Swig: