How does {{ timeout|default(0)|json }} work?

How does {{ timeout|default(0)|json }} work?

// bokeh/bokeh/core/_templates/autoload_nb_js.js:134,135

if (typeof (root._bokeh_timeout) === "undefined" || force === true) {
    root._bokeh_timeout = + {{ timeout|default(0)|json }};

My guess was that the default(0) sets the default for variable timeout to 0 and the json converts it to string '0'. Not sure why you would do that.
I couldn’t find any default() (in this syntax) and json filter in django template builtins.

You couldn’t find the filters because Bokeh doesn’t use Django, it uses Jinja templates.
The default filter:
And the json filter:

For why there is the json filter, I am not sure. It doesn’t change the value into a string because the template system handles it. It seems that it’s there just to make sure that we use only well-formed JSON values in JS files. Here’s the PR if you’re interested: