How to filter a template tag?

Many tags support as variablename -- that is, simple put as variablename at the end of the tag and then the output of that tag is placed in the variable rather than displayed.

This {% partial %} tag may support that. Here's an example, if it does:

{% partial "partials/vehicleform.html" vehicle=vehicles.empty_form as myvar %}{{ myvar|escapejs }}

If the tag in question is the "Partial tag" snippet then it appears it doesn't support this. But it probably could be rewritten to support it.

You could use the "Capture template output as a variable" snippet, and then apply the filter to the captured content, like so:

{% captureas myvar %}{% partial "partials/vehicleform.html" vehicle=vehicles.empty_form  %}{% endcaptureas %}{{ myvar|escapejs }}