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 = Date.now() + {{ 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: Template Designer Documentation — Jinja Documentation (3.0.x)
And the json filter: bokeh/templates.py at branch-3.0 · bokeh/bokeh · GitHub

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: Fix autoload templates to inject data into JS templates properly by mattpap · Pull Request #5603 · bokeh/bokeh · GitHub